home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / program / svgacc25.zip / SVGACC25.TXT < prev    next >
Text File  |  1997-03-24  |  306KB  |  13,670 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                   REFERENCE MANUAL
  9.  
  10.  
  11.                                      FOR SVGACC
  12.  
  13.  
  14.                                     THE SUPER VGA
  15.  
  16.  
  17.                                   GRAPHICS LIBRARY
  18.  
  19.  
  20.                                     FOR USE WITH
  21.  
  22.  
  23.                                       MICROSOFT
  24.  
  25.  
  26.                                   COMPATIBLE C/C++
  27.  
  28.  
  29.                                       COMPILERS
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.           1993-1996 by Zephyr Software - Stephen L. Balkum and Daniel A.
  52.           Sill
  53.  
  54.           All rights reserved.  No part of this book shall be reproduced or
  55.           transmitted by any means, electronic, mechanical, photocopying,
  56.           recording or otherwise, without written permission from Zephyr
  57.           Software - Stephen L. Balkum and Daniel A. Sill.
  58.  
  59.           Although every effort has been made to insure the accuracy of the
  60.           material in this book, Zephyr Software, Stephen L. Balkum and
  61.           Daniel A. Sill assume no responsibility for errors or omissions.
  62.           In addition no liability is assumed for damages resulting from
  63.           the use of the information contained herein.
  64.  
  65.           Printed in the United States of America
  66.  
  67.           Trademarks
  68.  
  69.           Sound Blaster and Sound Blaster Pro are trademarks of Creative
  70.           Labs, Inc.
  71.           All others are trademarks of their respective owners.
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.                                                                          ii
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.                              SOFTWARE LICENSE AGREEMENT
  100.  
  101.                By using this software, you agree to the terms of this
  102.                                      agreement.
  103.  
  104.                No warranties are expressed or implied.  In no event
  105.                shall Zephyr Software, Stephen L. Balkum or Daniel A.
  106.                Sill be held liable for damages resulting from the use
  107.                or misuse of this product, including but not limited to
  108.                implied warranties of fitness for a particular purpose.
  109.  
  110.                The shareware version may be freely distributed as long
  111.                as all files stay together and are not modified in any
  112.                way.  No cost may be charged for the shareware version
  113.                beyond normal and reasonable copying and distribution
  114.                expenses.
  115.  
  116.                No products developed with this software shall be sold
  117.                unless this software has been registered with Zephyr
  118.                Software, Stephen L. Balkum or Daniel A. Sill.
  119.  
  120.                At no time for any reason shall this software be
  121.                reverse engineered, decompiled or disassembled.
  122.  
  123.                This software may not be rented or leased.
  124.  
  125.                This software may be used only on one terminal or one
  126.                computer at any one given moment in time.  This
  127.                software may not be installed on a network of any type.
  128.                Contact Zephyr Software, Stephen L. Balkum or Daniel A.
  129.                Sill for networking options.
  130.  
  131.                United States Government Restricted Rights:
  132.                Use, duplication or disclosure of this software and
  133.                documentation by the U.S. Government is subject to the
  134.                restrictions as set forth in subparagraph (c)(1)(ii) of
  135.                the Rights in Technical Data and Computer Software
  136.                clause at DFARS 252.227-7013.  Contractor/manufacturer
  137.                is Stephen L. Balkum and Daniel A. Sill, P.O. Box 7704,
  138.                Austin, Texas 78713-7704.
  139.  
  140.                The ownership of this software may be transferred as
  141.                long as Zephyr Software, Stephen L. Balkum or Daniel A.
  142.                Sill is notified in writing of the transfer date and
  143.                new owner.  The new owner must agree to this contract.
  144.                The transfer must include all registered updates and
  145.                previously registered versions.  The original owner may
  146.                not retain any copies in any form of the registered
  147.                software or its documents.
  148.  
  149.  
  150.  
  151.  
  152.  
  153.                                                                         iii
  154.  
  155.  
  156.  
  157.  
  158.  
  159.           INTRODUCTION
  160.  
  161.           We spent weeks searching the depths of the internet ftp sites for
  162.           a library that would allow the programmer full access to the
  163.           abilities of Super VGA.  We wanted the colors VGA could provide
  164.           and better resolution than EGA could provide.  Professionally
  165.           developed libraries with this ability were definitely out of our
  166.           price range.  After our searches continuously returned nothing,
  167.           we decided to fill the apparent void in the shareware market.
  168.  
  169.           Our searches did give two useful packages:  John Bridges' VGAKIT
  170.           and Finn Thoegersen's VGADOC.  We began with these two works and
  171.           developed a graphics library intended to allow the programmer
  172.           access to the huge world of high resolution programming.
  173.  
  174.           On the surface the task appeared quite simple.  However, it
  175.           quickly became obvious that the routines in this library would be
  176.           required to affect extremely large amounts of data.  Operations
  177.           must be quick to be successful.  Therefore, every effort was made
  178.           to create the fastest code possible - even at the expense of
  179.           size.  For this reason we opted to write code with the 32 bit
  180.           instructions of the 80386 and better processors.  It is our
  181.           opinion that anyone with a hi-res card in a lesser machine may
  182.           have some priorities out of order.  All routines are written in
  183.           assembly and use absolutely no floating point values.  Anytime a
  184.           real number was required, fixed point notation was used.  In
  185.           addition we attempted to write the routines such that any
  186.           reasonable argument passed can be interpreted intelligently by
  187.           the library.
  188.  
  189.           With the numerous Super VGA cards available and no well
  190.           established standard we chose John Bridges' identification and
  191.           bank switching routines as a beginning.  These two routines have
  192.           undergone some modification, but not enough to justify
  193.           copyrighting this portion of the library's code by Zephyr
  194.           Software.  We have no intentions of releasing our changes to
  195.           these routines into the public domain.  From that point onward
  196.           all code is original.  In some instances common algorithms were
  197.           researched and original code written according to that algorithm.
  198.  
  199.           This Super VGA library gives the programmer transparent access to
  200.           twenty different Super VGA cards.  These cards include Acumos,
  201.           Ahead, ATI Technologies, Avance, Chips and Technologies, Cirrus
  202.           Logic, Everex, Genoa, MXIC, NCR, Oak Technologies,
  203.           Paradise/Western Digital, Primus, Realtek, Trident, Tseng Labs,
  204.           Video 7 and the VESA standard.  Please see the WHICHVGA function
  205.           for the specific chipsets.  The programmer only needs to verify
  206.           that the end user's card has been identified, but not which card
  207.           was recognized.  After proper identification, all functions react
  208.           in exactly the same fashion.  The library contains functions to
  209.           draw all of the major primitives.  In addition there are
  210.           functions that modify the screen palette, write text on the
  211.           screen with a choice of fonts and modify the reaction of the
  212.           primitives.  Identification routines include not only the video
  213.  
  214.  
  215.                                                                           2
  216.  
  217.  
  218.  
  219.  
  220.  
  221.           card, but also the amount of video memory, type of processor and
  222.           installed pointing devices.  Advanced functions provide full
  223.           mouse support (when used with a Microsoft compatible driver) and
  224.           joystick support.  Finally, support for two dimensional and three
  225.           dimensional coordinate systems is provided including rotation,
  226.           translation, scaling and projection.
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.                                                                           3
  278.  
  279.  
  280.  
  281.  
  282.  
  283.           SUGGESTED METHODS FOR USING THIS LIBRARY
  284.  
  285.           VERIFICATION OF A COMPUTER'S HARDWARE
  286.  
  287.           It is strongly recommended that any program written with this
  288.           library first verifies that the computer is a 80386 or better by
  289.           calling the WHICHCPU function.  Many of the library's functions
  290.           use 386 exclusive code which may cause a computer with a lesser
  291.           processor to crash.  In addition WHICHMOUSE must be called before
  292.           calling any of the mouse functions.  Lastly, it is recommended
  293.           that WHICHJOYSTICK be called before a program uses the joystick
  294.           routines.
  295.  
  296.           It is required that a program call WHICHVGA prior to any function
  297.           that communicates with the video card.  If WHICHVGA returns a
  298.           zero for unknown card type, the program should not call any
  299.           graphics function.  Without proper identification of the video
  300.           card any graphics function will likely cause a system failure.
  301.           It is recommended, although not necessary, that a program call
  302.           WHICHMEM prior to calling any RES function.  Although the video
  303.           card was properly identified, it may not have sufficient onboard
  304.           memory to support the desired resolution.  As a second check the
  305.           RES functions will do nothing if the video card has not been
  306.           identified or if the video card does not support the specified
  307.           resolution for memory or hardware reasons.
  308.  
  309.           THE 256 COLOR PALETTE
  310.  
  311.           The 256 color palette of the Super VGA cards is a six bit
  312.           palette.  Each of the 256 colors of the palette are described by
  313.           three values representing the intensity of the colors red, blue
  314.           and green.  These values can range from 0 to 63.  Anytime a value
  315.           outside of this range is used, the video card simply ignores the
  316.           upper two bits.  Therefore, 64 is the same as 0.  This should be
  317.           taken into consideration when manipulating the palette or when
  318.           importing a palette from an external source such as a PCX image.
  319.  
  320.           USE OF 2-D AND 3-D FUNCTIONS
  321.  
  322.           In the interest of speed, the 2-D and 3-D functions were written
  323.           to best work on multiple points at once.  We refer to these
  324.           functions as object-oriented.  This means that the points
  325.           defining an object (a box, a house, etc.) should be contained
  326.           within one array or part of an array and calls to the functions
  327.           should act on all of the points in the array.  Calls to functions
  328.           have a high speed overhead, therefore, placing more than one
  329.           object in the same array and passing the entire array to the
  330.           functions can be beneficial.  However, these functions will work
  331.           on a single point as well.
  332.  
  333.           A consequence of our object-oriented 2-D and 3-D functions is the
  334.           use of the scaling functions.  When scaling objects, we recommend
  335.           the object be defined about the origin.  D2SCALE and D3SCALE both
  336.           work with respect to the origin.  This eliminates a significant
  337.  
  338.  
  339.                                                                           4
  340.  
  341.  
  342.  
  343.  
  344.  
  345.           number of translations that would otherwise be required by having
  346.           a definable scale origin.  For example, to draw two boxes, one
  347.           scaled by one-half of the other, each rotated by 45 degrees at
  348.           the center of the screen, the recommended procedure is as
  349.           follows:
  350.  
  351.             define an array BOX containing the 2-D points: (100, 100), (-
  352.                100, 100), (-100, -100), (100, -100), (note: the box is
  353.                centered about the origin.)
  354.             rotate BOX by 45 degrees about (0, 0) and place the output in
  355.                RBOX,
  356.             scale RBOX by 50% (scaling factor would be 128, or 80 hex) and
  357.                place output in SRBOX,
  358.             translate RBOX to the center of the screen - a translation of
  359.                320, 240 in 640x480 resolution - and place output in TRBOX,
  360.             translate SRBOX to the center of the screen - same translation
  361.                as for RBOX - and place output in TSRBOX,
  362.             draw TRBOX and TSRBOX on the screen.
  363.  
  364.           Notice that by defining the box centered about the origin the
  365.           translation values were extremely intuitive.  Also notice that if
  366.           we had scaled the second box after the translation, it would have
  367.           been draw in the upper left quadrant of the screen instead of the
  368.           center.
  369.  
  370.           In mathematics and many sciences it is customary that in a 2-D
  371.           coordinate system the Y axis increases upward and the X axis
  372.           increases to the right.  The computer industry has decided the Y
  373.           axis should increase downward.  The 2-D functions are not
  374.           affected by the choice in coordinate systems.  However, it is
  375.           important to remember that a positive rotation in D2ROTATE
  376.           rotates from the positive X axis to the positive Y axis.
  377.           Therefore, when using mathematical conventions, a positive
  378.           rotation moves counter-clockwise.  On the computer screen a
  379.           positive rotation moves clockwise.
  380.  
  381.           The 3-D coordinate system follows mathematical conventions by
  382.           using a right-handed coordinate system.  The easiest way to
  383.           visualize this coordinate system is by using your right hand.
  384.           Place your index finger and thumb at a right angle to one another
  385.           as if to form an imaginary pistol.  Now place your second finger
  386.           at a right angle to your index finger.  It should be at a right
  387.           angle to your thumb as well.  This represents the three axes.
  388.           The index finger is the X axis, the second finger is the Y axis
  389.           and the thumb is the Z axis.  The easiest way to remember
  390.           rotation directions in this system is cyclically.  A positive
  391.           rotation about the X axis rotates the Y axis into the Z axis.  A
  392.           positive rotation about the Y axis rotates the Z axis into the X
  393.           axis.  A positive rotation about the Z axis rotates the X axis
  394.           into the Y axis.
  395.  
  396.           After doing all necessary 3-D transformations, projection onto
  397.           the 2-D computer screen is required.  Although the computer
  398.           screen's coordinate system does not follow mathematical
  399.  
  400.  
  401.                                                                           5
  402.  
  403.  
  404.  
  405.  
  406.  
  407.           conventions, the D3PROJECT function automatically takes care of
  408.           all conversions.  The programmer only needs to draw the resulting
  409.           object on the screen with FILLCONVEXPOLY, FILLPOLY or a series of
  410.           DRWLINEs.
  411.  
  412.           THE CONCEPT OF SPRITE GRAPHICS
  413.  
  414.           The key to sprite graphics is the assumption that only a small
  415.           percentage of the pixels in a graphics block are used by the
  416.           animation and the remaining pixels should be treated as
  417.           transparent, revealing the background behind the sprite.  The
  418.           sprite routines in this library only act on non-transparent
  419.           colors, thus, saving time by ignoring a large number of pixels.
  420.           When retrieving the background for a sprite, prior knowledge of
  421.           the sprite itself permits obtaining background only where it is
  422.           necessary.
  423.  
  424.           The following steps outline an example of the recommended
  425.           procedure for using the sprite functions:
  426.  
  427.             1. draw the sprite on the screen - a white stick figure on a
  428.                black background, for example
  429.             2. use BLKGET to place the sprite in an array STICK
  430.             3. use SPRITEGAP to simultaneously retrieve the background into
  431.                BACKSTICK and place STICK on the screen, declaring black as
  432.                the transparent color
  433.             4. use SPRITEPUT to replace the background BACKSTICK in the
  434.                same location as step 3
  435.             5. repeat steps 3 and 4 as many times and in as many locations
  436.                as desired
  437.  
  438.           GLOBAL VARIABLES
  439.  
  440.           Access to several global variables provided to the programmer.
  441.           The most important two variables are MAXX and MAXY.  These two
  442.           values give the current resolution and are set by the RES###
  443.           functions.  They should not be changed directly at any time by
  444.           the programmer.  Doing so may cause erratic results from many of
  445.           the graphics functions in this library.  These variables
  446.           initially contain 0.
  447.  
  448.           Four other variables, VIEWX1, VIEWY1, VIEWX2, VIEWY2, can be
  449.           accessed by the programmer.  They define the current viewport
  450.           used for clipping purposes.  These values, also, should not be
  451.           changed directly by the programmer.  The SETVIEW function should
  452.           be used to change these values as it performs important error
  453.           checking.  The viewport is defined as the whole screen by the
  454.           RES### functions.  If drawing on more or less than the entire
  455.           screen is desired, call SETVIEW as necessary.
  456.  
  457.           EXTENDED MEMORY SUPPORT
  458.  
  459.           With the higher screen resolutions, more memory may be needed for
  460.           data storage.  For this reason extended memory support is
  461.  
  462.  
  463.                                                                           6
  464.  
  465.  
  466.  
  467.  
  468.  
  469.           provided.  Accessing extended memory requires the computer to
  470.           switch into protected mode.  The process of switching into
  471.           protected mode and returning is handled by the extended memory
  472.           manager, usually HIMEM.SYS.  The switch is relatively slow.
  473.           Therefore, it should be used as fast storage access since it is
  474.           much faster than disk access.
  475.  
  476.           Extended memory access is also limited by the number of available
  477.           handles.  The limit is controlled by a switch on the extended
  478.           memory manager's command line and normally defaults to 32.  Also,
  479.           it is imperative that all allocated extended memory blocks be
  480.           freed before the program terminates.  Unfreed memory blocks will
  481.           be unavailable until the computer is rebooted.
  482.  
  483.           CONVENTIONS USED IN THIS MANUAL
  484.  
  485.           All parameters, other than pointers, passed to and from functions
  486.           and procedures in this graphics library are short (two byte)
  487.           integers  A byte variable type is assumed to be an unsigned
  488.           character.  No floating point values are used.  By not using real
  489.           numbers round-off error can be a concern.  Under most
  490.           circumstances this error will not be a problem and will not be
  491.           noticed.  The use of large numbers in rotations is recommended.
  492.  
  493.           No functions in this library allocate memory for the programmer,
  494.           except, of course, XMSALLOCATE.  It is the programmer's
  495.           responsibility to be sure all pointers reference properly
  496.           allocated memory of the appropriate size.
  497.  
  498.           Whenever a pixel is written on the screen, a mode is required.
  499.           Unless otherwise noted, there are five possible modes:
  500.           NO_ACTION, SET, XOR, OR and AND.  These modes are represented by
  501.           the numbers zero through four respectively.  NO_ACTION is self-
  502.           explanatory.  Technically, SET is the fastest mode.  However, XOR
  503.           maybe the most useful.  XOR'ing a point twice with the same color
  504.           returns the original color.  This can be used to cover and
  505.           uncover graphics.  In addition when a reference to a color index
  506.           is made, only values between and including 0 and 255 are valid.
  507.           Any integer will work, but only the lowest eight bits are
  508.           recognized.
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                           7
  526.  
  527.  
  528.  
  529.  
  530.  
  531.           BLKGET
  532.  
  533.             PROTOTYPE
  534.  
  535.             extern int far blkget (int x1, int y1, int x2, int y2,
  536.             RasterBlock far *gfxblk)
  537.  
  538.             INPUT
  539.  
  540.             x1, y1 - top left corner of block
  541.             x2, y2 - bottom right corner of block
  542.  
  543.             OUTPUT
  544.  
  545.             BLKGET returns 1 if successful, 0 if failed.
  546.             gfxblk - retrieved bitmap
  547.  
  548.             USAGE
  549.  
  550.             BLKGET stores the pixel data contained within the block
  551.             defined by (x1, y1)-(x2, y2) in the variable referenced by
  552.             gfxblk.  Memory for gfxblk must be allocated as a RasterBlock
  553.             structure with a data size in bytes equal to
  554.  
  555.                                  [(x2-x1+1)*(y2-y1+1)]
  556.  
  557.             plus four bytes for the width and height integers of the
  558.             RasterBlock structure.
  559.  
  560.             Note, however, that gfxblk can be quite large.  If the size of
  561.             gfxblk is insufficient, BLKGET will overwrite any data in
  562.             memory contained beyond gfxblk and may possibly cause the
  563.             system to crash.  In addition the segmented nature of real
  564.             mode programming requires that gfxblk be smaller 65536 bytes.
  565.             For larger blocks, see XMSBLKGET.  BLKGET enforces X2 X1 and
  566.             Y2 Y1.  Also, the coordinates must be valid on the screen at
  567.             the current resolution.
  568.  
  569.             SEE ALSO
  570.  
  571.             BLKPUT, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
  572.             SPRITEGET, SPRITEPUT, XMSBLKGET, XMSBLKPUT
  573.  
  574.             EXAMPLE
  575.  
  576.             /*
  577.              * Places 1/4 of a circle at the center of the screen
  578.              */
  579.             #include <stdlib.h>
  580.             #include <conio.h>
  581.             #include "svgacc.h"
  582.  
  583.             void main(void)
  584.             {
  585.  
  586.  
  587.                                                                           8
  588.  
  589.  
  590.  
  591.  
  592.  
  593.                int vmode;
  594.                int a,b,c,d;
  595.                RasterBlock *blkdata;
  596.  
  597.                vmode = videomodeget();
  598.                if ( !whichvga() || (whichmem() < 512))
  599.                  exit(1);
  600.                res640();
  601.                drwcircle(1,10,30,30,20);
  602.                fillarea(30,30,10,7);
  603.                a = b = 0;
  604.                c = d = 30;
  605.                blkdata = (RasterBlock *)malloc((c-a+1)*(d-b+1)+4);
  606.                blkget(a,b,c,d,blkdata);
  607.                blkput(1,320,240,blkdata);
  608.                getch();
  609.                videomodeset(vmode);
  610.                exit(0);
  611.             }
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.                                                                           9
  650.  
  651.  
  652.  
  653.  
  654.  
  655.           BLKPUT
  656.  
  657.             PROTOTYPE
  658.  
  659.             extern void far blkput (PixelMode mode, int x, int y,
  660.             RasterBlock far *gfxblk)
  661.  
  662.             INPUT
  663.  
  664.             mode - pixel write mode
  665.             x, y - location for top left corner of block
  666.             gfxblk - RasterBlock pointer to bitmap
  667.  
  668.             OUTPUT
  669.  
  670.             no value returned
  671.  
  672.             USAGE
  673.  
  674.             BLKPUT places the pixel data contained in the variable
  675.             referenced by gfxblk on the screen.  The top, left corner of
  676.             the block is specified by (X, Y).  Any (X, Y) is acceptable
  677.             and any portion of the block that lies outside of the
  678.             currently defined viewport will not be drawn.
  679.  
  680.             SEE ALSO
  681.  
  682.             BLKGET, BLKRESIZE, BLKROTATE, GETLASTSTRING, SPRITEGAP,
  683.             SPRITEGET, SPRITEPUT, PCXPUT, SETVIEW, XMSBLKGET, XMSBLKPUT
  684.  
  685.             EXAMPLE
  686.  
  687.             See BLKGET
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.                                                                          10
  712.  
  713.  
  714.  
  715.  
  716.  
  717.           BLKRESIZE
  718.  
  719.             PROTOTYPE
  720.  
  721.             extern void far blkresize (unsigned newxsize, unsigned
  722.                newysize, RasterBlock far *sourcegfxblk, RasterBlock far
  723.                *destgfxblk)
  724.  
  725.             INPUT
  726.  
  727.             newxsize, newysize - size of resulting bitmap in destgfxblk
  728.             sourcegfxblk - RasterBlock pointer to source bitmap
  729.  
  730.             OUTPUT
  731.  
  732.             no value returned
  733.             destgfxblk - resized bitmap
  734.  
  735.             USAGE
  736.  
  737.             BLKRESIZE takes the bitmap in sourcegfxblk and scales it up or
  738.             down according the to values passed in newxsize and newysize.
  739.             The resulting bitmap is returned in destgfxblk which should
  740.             already be declared with a size calculated according to the
  741.             equation in BLKGET.  Neither newxsize nor newysize should be
  742.             zero.
  743.  
  744.             SEE ALSO
  745.  
  746.             BLKGET, BLKPUT, BLKROTATE
  747.  
  748.             EXAMPLE
  749.  
  750.             /*
  751.              * Show blkresize
  752.              */
  753.             #include <stdlib.h>
  754.             #include <math.h>
  755.             #include <conio.h>
  756.             #include "svgacc.h"
  757.             #define randnum(size) (rand() % (int)(size))
  758.  
  759.             void main(void)
  760.             {
  761.                int vmode, i, j, colr, x1, y1, x2, y2;
  762.                RasterBlock *gfxblk1, *gfxblk2;
  763.  
  764.                vmode = videomodeget();
  765.                if ( !whichvga() || (whichmem() < 512))
  766.                  exit(1);
  767.                if ( !res640() )
  768.                  exit(1);
  769.                i=20000;
  770.                gfxblk1 = (RasterBlock *)malloc(i);
  771.  
  772.  
  773.                                                                          11
  774.  
  775.  
  776.  
  777.  
  778.  
  779.                if (!gfxblk1) {
  780.                  restext();
  781.                  printf("ERROR: Allocating memory for gfxblk1: %d
  782.             bytes\n",i);
  783.                  exit(1);
  784.                }
  785.                gfxblk2 = (RasterBlock *)malloc(i);
  786.                if (!gfxblk2) {
  787.                  restext();
  788.                  printf("ERROR: Allocating memory for gfxblk2: %d
  789.             bytes\n",i);
  790.                  exit(1);
  791.                }
  792.                for(i=0;i<=25;i++) {
  793.                  x1 = randnum(50);
  794.                  y1 = randnum(50);
  795.                  x2 = randnum(50);
  796.                  y2 = randnum(50);
  797.                  colr = randnum(16);
  798.                  drwline(1,colr,x1,y1,x2,y2);
  799.                }
  800.                x1 = 0;
  801.                y1 = 0;
  802.                x2 = 50;
  803.                y2 = 50;
  804.                drwbox(1,15,x1,y1,x2,y2);
  805.                blkget(x1,y1,x2,y2,gfxblk1);
  806.                x1 = maxx / 2;
  807.                y1 = maxy / 2;
  808.                blkresize(50,50,gfxblk1,gfxblk2);
  809.                blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  810.             >height)/2,gfxblk2);
  811.                for(i=x2;i<=x2+50;i++) {
  812.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  813.             >height)/2,gfxblk2);
  814.                  blkresize(i,i,gfxblk1,gfxblk2);
  815.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  816.             >height)/2,gfxblk2);
  817.                  sdelay(3);
  818.                }
  819.                for(i=x2+50;i>=x2-50;i--) {
  820.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  821.             >height)/2,gfxblk2);
  822.                  blkresize(i,i,gfxblk1,gfxblk2);
  823.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  824.             >height)/2,gfxblk2);
  825.                  sdelay(3);
  826.                }
  827.                for(i=x2-50;i<=x2+1;i++) {
  828.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  829.             >height)/2,gfxblk2);
  830.                  blkresize(i,i,gfxblk1,gfxblk2);
  831.                  blkput(2,x1-(gfxblk2->width)/2,y1-(gfxblk2-
  832.             >height)/2,gfxblk2);
  833.  
  834.  
  835.                                                                          12
  836.  
  837.  
  838.  
  839.  
  840.  
  841.                  sdelay(3);
  842.                }
  843.                getch();
  844.                videomodeset(vmode);
  845.                exit(0);
  846.             }
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.  
  866.  
  867.  
  868.  
  869.  
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.                                                                          13
  898.  
  899.  
  900.  
  901.  
  902.  
  903.           BLKROTATE
  904.  
  905.             PROTOTYPE
  906.  
  907.             extern int  far blkrotate (int ang, int backfill, RasterBlock
  908.             far *sourcegfxblk, RasterBlock far *destgfxblk)
  909.  
  910.             INPUT
  911.  
  912.             ang - integer degree to rotate source bitmap
  913.             backfill - index to color in current palette to fill blank
  914.             space in destgfxblk
  915.             sourcegfxblk - RasterBlock pointer to source bitmap
  916.  
  917.             OUTPUT
  918.  
  919.             BLKROTATE returns 1 if successful, 0 if unsuccessful.
  920.             destgfxblk - rotated bitmap
  921.  
  922.             USAGE
  923.  
  924.             BLKROTATE takes the bitmap in sourcegfxblk and rotates by the
  925.             number of degrees specified in ang.  The bitmap rotation
  926.             algorithm is a three-pass shear technique modified to make
  927.             efficient use of this library's internal buffers.  Blank space
  928.             around the newly rotated block is filled with the color given
  929.             by backfill.  The resulting bitmap is stored in destgfxblk.
  930.             The size of destgfxblk should be at least as big as given by
  931.             BLKROTATESIZE.
  932.  
  933.             The function will fail if it calculates that the internal
  934.             buffers would be overflowed or if the destination array would
  935.             be larger than 65536 bytes.  BLKROTATESIZE should be called
  936.             first to ensure that buffer integrity is maintained.
  937.  
  938.             SEE ALSO
  939.  
  940.             BLKGET, BLKPUT, BLKRESIZE, BLKROTATESIZE
  941.  
  942.             EXAMPLE
  943.  
  944.             /*
  945.              * Show blkrotate
  946.              */
  947.             #include <stdlib.h>
  948.             #include <math.h>
  949.             #include <conio.h>
  950.             #include "svgacc.h"
  951.  
  952.             void main(void)
  953.             {
  954.                int xinc, yinc, x1, y1, x2, y2, i, j, colr, vmode, cntx,
  955.             cnty, rot;
  956.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  957.  
  958.  
  959.                                                                          14
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.                vmode = videomodeget();
  967.                if ( !whichvga() || (whichmem() < 512))
  968.                  exit(1);
  969.                if ( !res640() )
  970.                  exit(1);
  971.                xinc = maxx/10;
  972.                yinc = maxy/20;
  973.                x1 = maxx/2-xinc;
  974.                y1 = maxy/2-yinc;
  975.                x2 = maxx/2+xinc;
  976.                y2 = maxy/2+yinc;
  977.                i = (x2-x1+1)*(y2-y1+1)+4;
  978.                gfxblk = (RasterBlock *)malloc(i);
  979.                if (!gfxblk) {
  980.                  restext();
  981.                  printf("ERROR: Allocating memory for gfxblk: %d
  982.             bytes\n",i);
  983.                  exit(1);
  984.                }
  985.                colr = 1;
  986.                for(i=0;i<=maxx/2;i++) {
  987.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  988.                  colr+=1;
  989.                  if(colr>15)
  990.                     colr = 1;
  991.                }
  992.                drwbox(1,0,x1,y1,x2,y2);
  993.                blkget(x1,y1,x2,y2,gfxblk);
  994.                cntx = (x2-x1) / 2 + x1;
  995.                cnty = (y2-y1) / 2 + y1;
  996.                fillarea(x1+2,y1+2,0,0);
  997.                i = blkrotatesize(45,gfxblk);
  998.                if ( !i ) {
  999.                  restext();
  1000.                  printf("ERROR: rotated sprite will be to large");
  1001.                  exit(1);
  1002.                }
  1003.                spritebkgnd = (RasterBlock *)malloc(i);
  1004.                if (!spritebkgnd) {
  1005.                  restext();
  1006.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  1007.             bytes\n",i);
  1008.                  exit(1);
  1009.                }
  1010.                gfxblk2 = (RasterBlock *)malloc(i);
  1011.                if (!gfxblk2) {
  1012.                  restext();
  1013.                  printf("ERROR: Allocating memory for gfxblk2: %d
  1014.             bytes\n",i);
  1015.                  exit(1);
  1016.                }
  1017.                blkget(x1,y1,x2,y2,spritebkgnd);
  1018.                setview(0,64,maxx,maxy);
  1019.  
  1020.  
  1021.                                                                          15
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.                for(i=0;i<=360;i+=3) {
  1028.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  1029.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  1030.             (spritebkgnd->height)/2,spritebkgnd);
  1031.                  spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  1032.             >height)/2,gfxblk2,spritebkgnd);
  1033.                  sdelay(3);
  1034.                }
  1035.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  1036.             (spritebkgnd->height)/2,spritebkgnd);
  1037.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  1038.                videomodeset(vmode);
  1039.                exit(0);
  1040.             }
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.  
  1069.  
  1070.  
  1071.  
  1072.  
  1073.  
  1074.  
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.                                                                          16
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.           BLKROTATESIZE
  1090.  
  1091.             PROTOTYPE
  1092.  
  1093.             extern int  far blkrotatesize (int ang, RasterBlock far
  1094.             *sourcegfxblk)
  1095.  
  1096.             INPUT
  1097.  
  1098.             ang - integer degree to rotate source bitmap
  1099.             sourcegfxblk - RasterBlock pointer to source bitmap
  1100.  
  1101.             OUTPUT
  1102.  
  1103.             BLKROTATESIZE returns the number of bytes needed for the
  1104.             destination array if successful, 0 if unsuccessful.
  1105.  
  1106.             USAGE
  1107.  
  1108.             BLKROTATESIZE takes the bitmap in sourcegfxblk and calculates
  1109.             the required size of the output buffer needed when BLKROTATE
  1110.             is called.  It also insures that the internal library buffers
  1111.             are not overflowed.  The function will fail if it calculates
  1112.             that the internal buffers would be overflowed or if the
  1113.             destination buffer would be larger than 65536 bytes.
  1114.             BLKROTATESIZE should be called prior to BLKROTATE to insure
  1115.             that buffer integrity is maintained.
  1116.  
  1117.             SEE ALSO
  1118.  
  1119.             BLKGET, BLKPUT, BLKRESIZE, BLKROTATE
  1120.  
  1121.             EXAMPLE
  1122.  
  1123.             See BLKROTATE
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.                                                                          17
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.           BYTECOPY
  1152.  
  1153.             PROTOTYPE
  1154.  
  1155.             extern void far bytecopy (void far *src, void far *dst, long
  1156.             numbytes)
  1157.  
  1158.             INPUT
  1159.  
  1160.             src - pointer to array to be copied
  1161.             numbytes - number of bytes to copy from src (<65536)
  1162.  
  1163.             OUTPUT
  1164.  
  1165.             no value returned
  1166.             dst - copy of array
  1167.  
  1168.             USAGE
  1169.  
  1170.             BYTECOPY copies the specified number of bytes from src to dst.
  1171.             It assumes that space for dst has been properly allocated.  It
  1172.             is much faster than using a FOR loop or MEMCPY.
  1173.  
  1174.             SEE ALSO
  1175.  
  1176.             PALCOPY
  1177.  
  1178.             EXAMPLE
  1179.  
  1180.             /*
  1181.              * show byte copy
  1182.              */
  1183.             #include <stdlib.h>
  1184.             #include <conio.h>
  1185.             #include "svgacc.h"
  1186.  
  1187.             void main(void)
  1188.             {
  1189.                int i;
  1190.                int test1[10], test2[10];
  1191.  
  1192.                for(i=0;i<10;i++)
  1193.                {
  1194.                  test1[i] = i;
  1195.                }
  1196.                bytecopy(test1,test2,sizeof(test1));
  1197.                printf("ok...we initialized one array with data, copied
  1198.             that\n");
  1199.                printf("array to an a new array...here are the results:\n");
  1200.                printf(" \n");
  1201.                printf("source array         destination array\n");
  1202.                for(i=0;i<10;i++)
  1203.                {
  1204.                  printf(" %d                    %d\n",test1[i],test2[i]);
  1205.  
  1206.  
  1207.                                                                          18
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.                }
  1214.                exit(0);
  1215.             }
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.                                                                          19
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.           D2ROTATE
  1276.  
  1277.             PROTOTYPE
  1278.  
  1279.             extern void far d2rotate (int points, int xorigin, int
  1280.             yorigin, int ang, D2Point far *inary, D2Point far *outary)
  1281.  
  1282.             INPUT
  1283.  
  1284.             numpoints - number of points to be rotated
  1285.             xorigin, yorigin - center of rotation
  1286.             angle - angle of rotation about center
  1287.             inary - D2Point pointer to array containing points to rotate
  1288.  
  1289.             OUTPUT
  1290.  
  1291.             no value returned
  1292.             outary - D2Point array of rotated values
  1293.  
  1294.             USAGE
  1295.  
  1296.             D2ROTATE takes the two dimensional points given in inary and
  1297.             rotates them by the specified angle about xorigin, yorigin.
  1298.             The results are returned in outary which can be the same as
  1299.             inary.  A positive angle causes a clockwise rotation on the
  1300.             screen, from the positive X axis to the positive Y axis.  The
  1301.             function assumes space for outary has been properly allocated.
  1302.  
  1303.             SEE ALSO
  1304.  
  1305.             D2SCALE, D2TRANSLATE
  1306.  
  1307.             EXAMPLE
  1308.  
  1309.             /*
  1310.              * shows d2rotate works
  1311.              */
  1312.  
  1313.             #include <stdlib.h>
  1314.             #include <conio.h>
  1315.             #include "svgacc.h"
  1316.  
  1317.             D2Point tri[3];
  1318.             D2Point trio[3];
  1319.             D2Point tri2[3];
  1320.  
  1321.             void drwtri(void);
  1322.             void ertri(void);
  1323.  
  1324.             void main(void)
  1325.             {
  1326.                int vmode,i;
  1327.  
  1328.                vmode = videomodeget();
  1329.  
  1330.  
  1331.                                                                          20
  1332.  
  1333.  
  1334.  
  1335.  
  1336.  
  1337.                if (!whichvga())
  1338.                  exit(1);
  1339.                if (whichmem()<512)
  1340.                  exit(1);
  1341.                res640();
  1342.                trio[0].x = 0;
  1343.                trio[0].y = 0;
  1344.                trio[1].x = -80;
  1345.                trio[1].y = 60;
  1346.                trio[2].x = 80;
  1347.                trio[2].y = 60;
  1348.                drwtri();
  1349.                for(i=0;i<=360;i+=2)
  1350.                {
  1351.                  d2rotate(3,0,0,i,trio,tri);
  1352.                  drwtri();
  1353.                  sdelay(2);
  1354.                  ertri();
  1355.                }
  1356.                drwtri();
  1357.                getch();
  1358.                videomodeset(vmode);
  1359.                exit(0);
  1360.             }
  1361.  
  1362.             void drwtri(void)
  1363.             {
  1364.                d2translate(3,320,240,tri,tri2);
  1365.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1366.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1367.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1368.                return;
  1369.             }
  1370.  
  1371.             void ertri(void)
  1372.             {
  1373.                d2translate(3,320,240,tri,tri2);
  1374.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1375.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1376.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1377.                return;
  1378.             }
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.                                                                          21
  1394.  
  1395.  
  1396.  
  1397.  
  1398.  
  1399.           D2SCALE
  1400.  
  1401.             PROTOTYPE
  1402.  
  1403.             extern void far d2scale (int points, int scalex, int scaley,
  1404.             D2Point far *inary, D2Point far *outary)
  1405.  
  1406.             INPUT
  1407.  
  1408.             numpoints - number of points to scale
  1409.             scalex - scale factor along X axis
  1410.             scaley - scale factor along Y axis
  1411.             inary - D2Point pointer to array containing points to scale
  1412.  
  1413.             OUTPUT
  1414.  
  1415.             no value returned
  1416.             outary - D2Point array of scaled values
  1417.  
  1418.             USAGE
  1419.  
  1420.             D2SCALE multiplies each coordinate in the two dimensional
  1421.             array inary by the corresponding scale factor scalex or
  1422.             scaley.  The results are stored in outary which can be the
  1423.             same as inary.  A scale factor of 256 (100 hex) is considered
  1424.             100 percent and results in no change.  Therefore, 128 (80 hex)
  1425.             reduces values by one half and 512 (200 hex) doubles values.
  1426.             The function assumes space for outary has been properly
  1427.             allocated.
  1428.  
  1429.             SEE ALSO
  1430.  
  1431.             D2ROTATE, D2TRANSLATE
  1432.  
  1433.             EXAMPLE
  1434.  
  1435.             /*
  1436.              * shows d2scale works
  1437.              */
  1438.  
  1439.             #include <stdlib.h>
  1440.             #include <conio.h>
  1441.             #include "svgacc.h"
  1442.  
  1443.             D2Point tri[3];
  1444.             D2Point trio[3];
  1445.             D2Point tri2[3];
  1446.  
  1447.             void drwtri(void);
  1448.             void ertri(void);
  1449.  
  1450.             void main(void)
  1451.             {
  1452.                int vmode,i;
  1453.  
  1454.  
  1455.                                                                          22
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.                vmode = videomodeget();
  1463.                if (!whichvga())
  1464.                  exit(1);
  1465.                if (whichmem()<512)
  1466.                  exit(1);
  1467.                res640();
  1468.                trio[0].x = 0;
  1469.                trio[0].y = 0;
  1470.                trio[1].x = -80;
  1471.                trio[1].y = 60;
  1472.                trio[2].x = 80;
  1473.                trio[2].y = 60;
  1474.                drwtri();
  1475.                for(i=256;i<=512;i+=4)
  1476.                {
  1477.                  d2scale(3,i,i,trio,tri);
  1478.                  drwtri();
  1479.                  sdelay(2);
  1480.                  ertri();
  1481.                }
  1482.                for(i=512;i>=128;i-=4)
  1483.                {
  1484.                  d2scale(3,i,i,trio,tri);
  1485.                  drwtri();
  1486.                  sdelay(2);
  1487.                  ertri();
  1488.                }
  1489.                for(i=128;i<=256;i+=4)
  1490.                {
  1491.                  d2scale(3,i,i,trio,tri);
  1492.                  drwtri();
  1493.                  sdelay(2);
  1494.                  ertri();
  1495.                }
  1496.                drwtri();
  1497.                getch();
  1498.                videomodeset(vmode);
  1499.                exit(0);
  1500.             }
  1501.  
  1502.             void drwtri(void)
  1503.             {
  1504.                d2translate(3,320,240,tri,tri2);
  1505.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1506.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1507.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1508.                return;
  1509.             }
  1510.  
  1511.             void ertri(void)
  1512.             {
  1513.                d2translate(3,320,240,tri,tri2);
  1514.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1515.  
  1516.  
  1517.                                                                          23
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1524.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1525.                return;
  1526.             }
  1527.  
  1528.  
  1529.  
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546.  
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  
  1565.  
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.                                                                          24
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.           D2TRANSLATE
  1586.  
  1587.             PROTOTYPE
  1588.  
  1589.             extern void far d2translate (int points, int xtrans, int
  1590.             ytrans, D2Point far *inary, D2Point far *outary)
  1591.  
  1592.             INPUT
  1593.  
  1594.             numpoints - number of points to be translated
  1595.             xtrans - distance to translate along X axis
  1596.             ytrans - distance to translate along Y axis
  1597.             inary - D2Point pointer to array containing points to
  1598.             translate
  1599.  
  1600.             OUTPUT
  1601.  
  1602.             no value returned
  1603.             outary - D2Point array of translated values
  1604.  
  1605.             USAGE
  1606.  
  1607.             D2TRANSLATE takes the two dimensional points given in inary
  1608.             and translates them by the specified number of pixels along
  1609.             each axis.  The results are returned in outary which can be
  1610.             the same as inary.  The function assumes that space for outary
  1611.             has been properly allocated.
  1612.  
  1613.             SEE ALSO
  1614.  
  1615.             D2ROTATE, D2SCALE
  1616.  
  1617.             EXAMPLE
  1618.  
  1619.             /*
  1620.              * shows d2translate works
  1621.              */
  1622.  
  1623.             #include <stdlib.h>
  1624.             #include <conio.h>
  1625.             #include "svgacc.h"
  1626.  
  1627.             D2Point tri[3];
  1628.             D2Point trio[3];
  1629.             D2Point tri2[3];
  1630.  
  1631.             void drwtri(void);
  1632.             void ertri(void);
  1633.  
  1634.             void main(void)
  1635.             {
  1636.                int vmode,i;
  1637.  
  1638.                vmode = videomodeget();
  1639.  
  1640.  
  1641.                                                                          25
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.                if (!whichvga())
  1648.                  exit(1);
  1649.                if (whichmem()<512)
  1650.                  exit(1);
  1651.                res640();
  1652.                trio[0].x = 0;
  1653.                trio[0].y = 0;
  1654.                trio[1].x = -80;
  1655.                trio[1].y = 60;
  1656.                trio[2].x = 80;
  1657.                trio[2].y = 60;
  1658.                drwtri();
  1659.                for(i=0;i<=100;i+=4)
  1660.                {
  1661.                  d2translate(3,i,i,trio,tri);
  1662.                  drwtri();
  1663.                  sdelay(2);
  1664.                  ertri();
  1665.                }
  1666.                for(i=100;i>=0;i-=4)
  1667.                {
  1668.                  d2translate(3,i,i,trio,tri);
  1669.                  drwtri();
  1670.                  sdelay(2);
  1671.                  ertri();
  1672.                }
  1673.                drwtri();
  1674.                getch();
  1675.                videomodeset(vmode);
  1676.                exit(0);
  1677.             }
  1678.  
  1679.             void drwtri(void)
  1680.             {
  1681.                d2translate(3,320,240,tri,tri2);
  1682.                drwline(1,10,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1683.                drwline(1,10,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1684.                drwline(1,10,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1685.                return;
  1686.             }
  1687.  
  1688.             void ertri(void)
  1689.             {
  1690.                d2translate(3,320,240,tri,tri2);
  1691.                drwline(1,0,tri2[0].x,tri2[0].y,tri2[1].x,tri2[1].y);
  1692.                drwline(1,0,tri2[1].x,tri2[1].y,tri2[2].x,tri2[2].y);
  1693.                drwline(1,0,tri2[2].x,tri2[2].y,tri2[0].x,tri2[0].y);
  1694.                return;
  1695.             }
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.                                                                          26
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.           D3PROJECT
  1710.  
  1711.             PROTOTYPE
  1712.  
  1713.             extern int far d3project (int points, ProjParameters far
  1714.             *params, D3Point far *inary, D2Point far *outary)
  1715.  
  1716.             INPUT
  1717.  
  1718.             numpoints - number of points to be projected
  1719.             params - pointer to ProjParameters structure containing
  1720.             parameters used in projection
  1721.                eyex, eyey, eyez - 3D location of viewer
  1722.                scrd - distance from viewer to projection screen
  1723.                theta - angle from positive 3D X axis to viewing direction
  1724.                phi - angle from positive 3D Z axis to viewing direction
  1725.             inary - D3Point pointer to array containing points to project
  1726.  
  1727.             OUTPUT
  1728.  
  1729.             Returns 1 if successful, 0 if any one point failed.
  1730.             outary - D2Point array of projected values
  1731.  
  1732.             USAGE
  1733.                                 +Z axis
  1734.                                    |                   /\
  1735.                                    |                  /  \
  1736.                                    |            !     \ * \
  1737.                                    |            !......X: /
  1738.                                    |            ! Phi / \/
  1739.                                    |            !    /  :
  1740.                                    |            !   /   :
  1741.                                    |            !  /    :
  1742.                                    |       EyeX ! /ScrD :
  1743.                                    |       EyeY !/      :
  1744.                                    |       EyeZ *- - - -:- - - - -
  1745.                                    |           / `      :
  1746.                                    |          /   `     :
  1747.                                    |         /      `   :
  1748.                                    |        /      ---` :
  1749.                                    |       /___----
  1750.                                    |      /     Theta
  1751.                                    |
  1752.                                    |_____________________________+Y axis
  1753.                                    /
  1754.                                   /
  1755.                                  /
  1756.                                 /
  1757.                                /
  1758.                               /
  1759.                              /
  1760.                          +X axis
  1761.  
  1762.  
  1763.  
  1764.  
  1765.                                                                          27
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.             D3PROJECT projects a specified number, numpoints, of three
  1772.             dimensional points starting at inary into two dimensions
  1773.             according to the parameters in params.  The two dimensional
  1774.             points are stored in outary.  The function assumes space for
  1775.             outary has been properly allocated.  The location of the
  1776.             viewer in this three dimensional space is given by eyex, eyey,
  1777.             eyez in the ProjParameters structure.  The direction the
  1778.             viewer is facing is specified with scrd, theta, phi in the
  1779.             ProjParameters structure using spherical coordinates.  A
  1780.             virtual set of axes parallel to the true axes are placed at
  1781.             the viewer's location.  scrd is the distance from the viewer
  1782.             to the center of the projection screen, i.e. the currently
  1783.             defined viewport on the monitor's screen.  Theta is the angle
  1784.             in the virtual X-Y plane from the virtual X axis to the
  1785.             projection screen.  Positive angles rotate counter-clockwise
  1786.             in the X-Y plane.  Lastly, the angle of elevation above or
  1787.             below the virtual X-Y plane is given by phi.  Positive angles
  1788.             direct viewing above the plane; negative below.
  1789.  
  1790.             If a point is projected to a location behind the viewer, i.e.
  1791.             on the side of the viewer opposite the projection screen,
  1792.             D3PROJECT returns a zero indicating one or more failed points.
  1793.             The returned values of the X and Y for failed points will be -
  1794.             32768 to make them easily identified.
  1795.  
  1796.             SEE ALSO
  1797.  
  1798.             D3ROTATE, D3TRANSLATE, D3SCALE, FILLCONVEXPOLY, SETVIEW
  1799.  
  1800.             EXAMPLE
  1801.  
  1802.             /* shows d3project works */
  1803.             #include <stdlib.h>
  1804.             #include <conio.h>
  1805.             #include "svgacc.h"
  1806.  
  1807.             D2Point plot[8];
  1808.             void drwcube(void);
  1809.  
  1810.             void main(void)
  1811.             {
  1812.                int vmode,i,dummy;
  1813.                ProjParameters proj;
  1814.                D3Point cube[8] = { { 100,-100, 100},
  1815.                                 { 100,-100,-100},
  1816.                                 { 100, 100,-100},
  1817.                                 { 100, 100, 100},
  1818.                                 {-100,-100, 100},
  1819.                                 {-100,-100,-100},
  1820.                                 {-100, 100,-100},
  1821.                                 {-100, 100, 100}};
  1822.  
  1823.                vmode = videomodeget();
  1824.                if (!whichvga())
  1825.  
  1826.  
  1827.                                                                          28
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.                  exit(1);
  1834.                if (whichmem()<512)
  1835.                  exit(1);
  1836.                res640();
  1837.                proj.eyex = -1040;
  1838.                proj.eyey = -600;
  1839.                proj.eyez = -1200;
  1840.                proj.scrd = 1700;
  1841.                proj.theta = 30;
  1842.                proj.phi = 45;
  1843.                dummy = d3project(8,&proj,cube,plot);
  1844.                drwcube();
  1845.                getch();
  1846.                videomodeset(vmode);
  1847.             }
  1848.  
  1849.             void drwcube(void)
  1850.             {
  1851.                int i;
  1852.  
  1853.                for(i=0;i<=2;i++)
  1854.  
  1855.                drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
  1856.                drwline(1,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  1857.                for(i=4;i<=6;i++)
  1858.  
  1859.                drwline(1,10,plot[i].x,plot[i].y,plot[i+1].x,plot[i+1].y);
  1860.                drwline(1,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  1861.                for(i=0;i<=3;i++)
  1862.  
  1863.                drwline(1,10,plot[i].x,plot[i].y,plot[i+4].x,plot[i+4].y);
  1864.                return;
  1865.             }
  1866.  
  1867.  
  1868.  
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.  
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.                                                                          29
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.           D3ROTATE
  1896.  
  1897.             PROTOTYPE
  1898.  
  1899.             extern void far d3rotate (int points, int xorigin, int
  1900.                yorigin, int zorigin, int zrang, int yrang, int xrang,
  1901.                D3Point far *inary, D3Point far *outary)
  1902.  
  1903.             INPUT
  1904.  
  1905.             numpoints - number of points to be rotated
  1906.             xorigin, yorigin, zorigin - center of rotation
  1907.             zrang - angle of rotation about the Z axis
  1908.             yrang - angle of rotation about the Y axis
  1909.             xrang - angle of rotation about the X axis
  1910.             inary - D3Point pointer to array containing points to rotate
  1911.  
  1912.             OUTPUT
  1913.  
  1914.             no value returned
  1915.             outary - D3Point array of rotated values
  1916.  
  1917.             USAGE
  1918.  
  1919.             D3ROTATE takes the three dimensional points given in inary and
  1920.             rotates them by the specified angles about xorigin, yorigin,
  1921.             zorigin.  The results are returned in outary which can be the
  1922.             same as inary.  A virtual set of axes are placed at the origin
  1923.             of rotation and rotation takes place about these axes.  A
  1924.             positive angle causes a counter-clockwise rotation from the
  1925.             positive X axis to the positive Y axis.  The function assumes
  1926.             space for outary has been properly allocated.
  1927.  
  1928.             SEE ALSO
  1929.  
  1930.             D3PROJECT, D3SCALE, D3TRANSLATE
  1931.  
  1932.             EXAMPLE
  1933.  
  1934.             /*
  1935.              * shows d3rotate works
  1936.              */
  1937.  
  1938.             #include <stdlib.h>
  1939.             #include <conio.h>
  1940.             #include "svgacc.h"
  1941.  
  1942.             D2Point plot[8];
  1943.  
  1944.             void drwcube(void);
  1945.  
  1946.             void main(void)
  1947.             {
  1948.                int vmode,i,dummy;
  1949.  
  1950.  
  1951.                                                                          30
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.                ProjParameters proj;
  1958.                D3Point rcube[8];
  1959.                D3Point cube[8] = { { 100,-100, 100},
  1960.                                 { 100,-100,-100},
  1961.                                 { 100, 100,-100},
  1962.                                 { 100, 100, 100},
  1963.                                 {-100,-100, 100},
  1964.                                 {-100,-100,-100},
  1965.                                 {-100, 100,-100},
  1966.                                 {-100, 100, 100}};
  1967.  
  1968.                vmode = videomodeget();
  1969.                if (!whichvga() || (whichmem() < 512))
  1970.                  exit(1);
  1971.                res640();
  1972.  
  1973.                proj.eyex = -1040;
  1974.                proj.eyey = -600;
  1975.                proj.eyez = -1200;
  1976.                proj.scrd = 1700;
  1977.                proj.theta = 30;
  1978.                proj.phi = 45;
  1979.  
  1980.                for(i=0;i<=360;i+=2)
  1981.                {
  1982.                  d3rotate(8,0,0,0,i,i,i,cube,rcube);
  1983.                  dummy = d3project(8,&proj,rcube,plot);
  1984.                  drwcube();
  1985.                  sdelay(2);
  1986.                  drwcube();
  1987.                }
  1988.  
  1989.                drwcube();
  1990.  
  1991.                getch();
  1992.  
  1993.                videomodeset(vmode);
  1994.             }
  1995.  
  1996.             void drwcube(void)
  1997.             {
  1998.                int j;
  1999.  
  2000.                for(j=0;j<=2;j++)
  2001.  
  2002.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2003.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2004.  
  2005.                for(j=4;j<=6;j++)
  2006.  
  2007.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2008.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2009.  
  2010.                for(j=0;j<=3;j++)
  2011.  
  2012.  
  2013.                                                                          31
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2021.  
  2022.                return;
  2023.             }
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.  
  2059.  
  2060.  
  2061.  
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067.  
  2068.  
  2069.  
  2070.  
  2071.  
  2072.  
  2073.  
  2074.  
  2075.                                                                          32
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.           D3SCALE
  2082.  
  2083.             PROTOTYPE
  2084.  
  2085.             extern void far d3scale (int points, int xscale, int yscale,
  2086.                int zscale, D3Point far *inary, D3Point far *outary)
  2087.  
  2088.             INPUT
  2089.  
  2090.             numpoints - number of points to scale
  2091.             xscale - scale factor along X axis
  2092.             yscale - scale factor along Y axis
  2093.             zscale - scale factor along Z axis
  2094.             inary - D3Point pointer to array containing points to scale
  2095.  
  2096.             OUTPUT
  2097.  
  2098.             no value returned
  2099.             outary - D3Point array of scaled values
  2100.  
  2101.             USAGE
  2102.  
  2103.             D3SCALE multiplies each coordinate in the three dimensional
  2104.             array inary by the corresponding scale factor xscale, yscale
  2105.             or zscale.  The results are stored in outary which can be the
  2106.             same as inary.  A scale factor of 256 (100 hex) is considered
  2107.             100 percent and results in no change.  Therefore, 128 (80 hex)
  2108.             reduces values by one half and 512 (200 hex) doubles values.
  2109.             The function assumes space for outary has been properly
  2110.             allocated.
  2111.  
  2112.             SEE ALSO
  2113.  
  2114.             D3PROJECT, D3ROTATE, D3TRANSLATE
  2115.  
  2116.             EXAMPLE
  2117.  
  2118.             /*
  2119.              * shows d3scale works
  2120.              */
  2121.  
  2122.             #include <stdlib.h>
  2123.             #include <conio.h>
  2124.             #include "svgacc.h"
  2125.  
  2126.             D2Point plot[8];
  2127.  
  2128.             void drwcube(void);
  2129.  
  2130.             void main(void)
  2131.             {
  2132.                int vmode,i,dummy;
  2133.                ProjParameters proj;
  2134.                D3Point scube[8];
  2135.  
  2136.  
  2137.                                                                          33
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.                D3Point cube[8] = { { 100,-100, 100},
  2144.                                 { 100,-100,-100},
  2145.                                 { 100, 100,-100},
  2146.                                 { 100, 100, 100},
  2147.                                 {-100,-100, 100},
  2148.                                 {-100,-100,-100},
  2149.                                 {-100, 100,-100},
  2150.                                 {-100, 100, 100}};
  2151.  
  2152.                vmode = videomodeget();
  2153.                if (!whichvga() || (whichmem() < 512))
  2154.                  exit(1);
  2155.                res640();
  2156.  
  2157.                proj.eyex = -1040;
  2158.                proj.eyey = -600;
  2159.                proj.eyez = -1200;
  2160.                proj.scrd = 1700;
  2161.                proj.theta = 30;
  2162.                proj.phi = 45;
  2163.  
  2164.                for(i=256;i>=128;i-=4)
  2165.                {
  2166.                  d3scale(8,i,i,i,cube,scube);
  2167.                  dummy = d3project(8,&proj,scube,plot);
  2168.                  drwcube();
  2169.                  sdelay(2);
  2170.                  drwcube();
  2171.                }
  2172.                for(i=132;i<=256;i+=4)
  2173.                {
  2174.                  d3scale(8,i,i,i,cube,scube);
  2175.                  dummy = d3project(8,&proj,scube,plot);
  2176.                  drwcube();
  2177.                  sdelay(2);
  2178.                  drwcube();
  2179.                }
  2180.                drwcube();
  2181.                getch();
  2182.                videomodeset(vmode);
  2183.             }
  2184.  
  2185.             void drwcube(void)
  2186.             {
  2187.                int j;
  2188.  
  2189.                for(j=0;j<=2;j++)
  2190.  
  2191.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2192.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2193.  
  2194.                for(j=4;j<=6;j++)
  2195.  
  2196.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2197.  
  2198.  
  2199.                                                                          34
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2206.  
  2207.                for(j=0;j<=3;j++)
  2208.  
  2209.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2210.  
  2211.                return;
  2212.             }
  2213.  
  2214.  
  2215.  
  2216.  
  2217.  
  2218.  
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.                                                                          35
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.           D3TRANSLATE
  2268.  
  2269.             PROTOTYPE
  2270.  
  2271.             extern void far d3translate (int points, int xtrans, int
  2272.                ytrans, int ztrans, D3Point far *inary, D3Point far *outary)
  2273.  
  2274.             INPUT
  2275.  
  2276.             numpoints - number of points to translate
  2277.             xtrans - distance to translate along X axis
  2278.             ytrans - distance to translate along Y axis
  2279.             ztrans - distance to translate along Z axis
  2280.             inary - D3Point pointer to array containing points to
  2281.             translate
  2282.  
  2283.             OUTPUT
  2284.  
  2285.             no value returned
  2286.             outary - D3Point array of translated points
  2287.  
  2288.             USAGE
  2289.  
  2290.             D3TRANSLATE takes the three dimensional points given in inary
  2291.             and translates them by the specified number of pixels along
  2292.             each axis.  The results are returned in outary which can be
  2293.             the same as inary.  The function assumes space for outary has
  2294.             been properly allocated.
  2295.  
  2296.             SEE ALSO
  2297.  
  2298.             D3PROJECT, D3ROTATE, D3SCALE
  2299.  
  2300.             EXAMPLE
  2301.  
  2302.             /*
  2303.              * shows d3translate works
  2304.              */
  2305.  
  2306.             #include <stdlib.h>
  2307.             #include <conio.h>
  2308.             #include "svgacc.h"
  2309.  
  2310.             D2Point plot[8];
  2311.  
  2312.             void drwcube(void);
  2313.  
  2314.             void main(void)
  2315.             {
  2316.                int vmode,i,dummy;
  2317.                ProjParameters proj;
  2318.                D3Point tcube[8];
  2319.                D3Point cube[8] = { { 100,-100, 100},
  2320.                                 { 100,-100,-100},
  2321.  
  2322.  
  2323.                                                                          36
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.                                 { 100, 100,-100},
  2330.                                 { 100, 100, 100},
  2331.                                 {-100,-100, 100},
  2332.                                 {-100,-100,-100},
  2333.                                 {-100, 100,-100},
  2334.                                 {-100, 100, 100}};
  2335.  
  2336.                vmode = videomodeget();
  2337.                if (!whichvga() || (whichmem() < 512))
  2338.                  exit(1);
  2339.                res640();
  2340.  
  2341.                proj.eyex = -1040;
  2342.                proj.eyey = -600;
  2343.                proj.eyez = -1200;
  2344.                proj.scrd = 1700;
  2345.                proj.theta = 30;
  2346.                proj.phi = 45;
  2347.  
  2348.                for(i=0;i<=400;i+=8)
  2349.                {
  2350.                  d3translate(8,i,i,i,cube,tcube);
  2351.                  dummy = d3project(8,&proj,tcube,plot);
  2352.                  drwcube();
  2353.                  sdelay(2);
  2354.                  drwcube();
  2355.                }
  2356.                for(i=400;i>=0;i-=8)
  2357.                {
  2358.                  d3translate(8,i,i,i,cube,tcube);
  2359.                  dummy = d3project(8,&proj,tcube,plot);
  2360.                  drwcube();
  2361.                  sdelay(2);
  2362.                  drwcube();
  2363.                }
  2364.                drwcube();
  2365.                getch();
  2366.                videomodeset(vmode);
  2367.             }
  2368.  
  2369.             void drwcube(void)
  2370.             {
  2371.                int j;
  2372.  
  2373.                for(j=0;j<=2;j++)
  2374.  
  2375.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2376.                drwline(2,10,plot[3].x,plot[3].y,plot[0].x,plot[0].y);
  2377.  
  2378.                for(j=4;j<=6;j++)
  2379.  
  2380.                drwline(2,10,plot[j].x,plot[j].y,plot[j+1].x,plot[j+1].y);
  2381.                drwline(2,10,plot[7].x,plot[7].y,plot[4].x,plot[4].y);
  2382.  
  2383.  
  2384.  
  2385.                                                                          37
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.                for(j=0;j<=3;j++)
  2392.  
  2393.                drwline(2,10,plot[j].x,plot[j].y,plot[j+4].x,plot[j+4].y);
  2394.  
  2395.                return;
  2396.             }
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.  
  2422.  
  2423.  
  2424.  
  2425.  
  2426.  
  2427.  
  2428.  
  2429.  
  2430.  
  2431.  
  2432.  
  2433.  
  2434.  
  2435.  
  2436.  
  2437.  
  2438.  
  2439.  
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.                                                                          38
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.           DRWALINE
  2454.  
  2455.             PROTOTYPE
  2456.  
  2457.             extern void far drwaline (colrbits, int colr, int x1, int y1,
  2458.             int x2, int y2)
  2459.  
  2460.             INPUT
  2461.  
  2462.             colrbits - number of bits of color
  2463.             colr - index to color in current palette
  2464.             x1, y1 - location of one endpoint of line
  2465.             x2, y2 - location of other endpoint of line
  2466.  
  2467.             OUTPUT
  2468.  
  2469.             no value returned
  2470.  
  2471.             USAGE
  2472.  
  2473.             DRWALINE draws an antialiased line of the specified color
  2474.             using with endpoints located at (x1, y1) and (x2,y2).
  2475.             Antialiased lines trick the eye into seeing true vector lines
  2476.             instead of a jagged series of individual pixels.  This is
  2477.             accomplished by drawing two pixels of the same color but with
  2478.             different intensities (brightness) for each pixel drawn by
  2479.             DRWALINE.  The eye averages the pixels and sees only a
  2480.             straight line.  Note that the palette must be set up with the
  2481.             correct color entries for the line to look correct.  All
  2482.             values of x1, y1, x2 and y2 are valid.  Any portion of the
  2483.             line that lies outside of the currently defined viewport will
  2484.             not be drawn.  Colrbits should be a number in the range of 0
  2485.             to 6 specifying the number of shades of color in the palette
  2486.             (20 =1 is one color shade; 26=64 is 64 shades of color).
  2487.             These shades should be contiguous in the palette from index
  2488.             colr to index (colr + 2colrbits - 1) starting with the full
  2489.             desired brightness.  The best compromise of detail versus
  2490.             palette entries is about 3 (23=8 is 8 shades, or palette
  2491.             entries, of color).
  2492.  
  2493.             SEE ALSO
  2494.  
  2495.             DRWLINE, DRWBOX, SETVIEW
  2496.  
  2497.             EXAMPLE
  2498.  
  2499.             /*
  2500.              * Draws some normal and antialiased lines
  2501.              */
  2502.  
  2503.             #include <stdlib.h>
  2504.             #include <conio.h>
  2505.             #include <math.h>
  2506.             #include "svgacc.h"
  2507.  
  2508.  
  2509.                                                                          39
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.             void main(void)
  2517.             {
  2518.                int i,y,ya,yb,ofst,coloroffset,intsbits,numlevels,dummy;
  2519.                PaletteData pal;
  2520.                if ( !whichvga() )
  2521.                     exit(1);
  2522.                 if ( whichmem() < 512)
  2523.                  exit(1);
  2524.                 if ( !res640() )
  2525.                  exit(1);
  2526.                /* set up the palette */
  2527.                intsbits=2;
  2528.                numlevels=pow(2,intsbits);
  2529.                coloroffset=16;
  2530.                palget(pal,0,255);
  2531.                for (i=0;i<numlevels;i++) {
  2532.                  pal[i+coloroffset].r = (char)(63-35*i/(numlevels-1));
  2533.                  pal[i+coloroffset].g = (char)(63-35*i/(numlevels-1));
  2534.                  pal[i+coloroffset].b = (char)(63-35*i/(numlevels-1));
  2535.                }
  2536.                palset(pal,0,255);
  2537.                ofst=maxy/2;
  2538.                ya=maxy/3;
  2539.                yb=2*maxy/3;
  2540.                for(y=0;y<ofst;y=y+12) {
  2541.                  drwline(SET,15,0,ya,maxx,y);
  2542.                  drwaline(intsbits,16,0,yb,maxx,ofst+y);
  2543.                }
  2544.                getch();
  2545.                dummy=restext();
  2546.                exit(0);
  2547.             }
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.  
  2568.  
  2569.  
  2570.  
  2571.                                                                          40
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.           DRWBOX
  2578.  
  2579.             PROTOTYPE
  2580.  
  2581.             extern void far drwbox (PixelMode mode, int colr, int x1, int
  2582.             y1, int x2, int y2)
  2583.  
  2584.             INPUT
  2585.  
  2586.             mode - pixel write mode
  2587.             colr - index to color in current palette
  2588.             x1, y1 - location of top left corner
  2589.             x2, y2 - location of bottom right corner
  2590.  
  2591.             OUTPUT
  2592.  
  2593.             no value returned
  2594.  
  2595.             USAGE
  2596.  
  2597.             DRWBOX draws a rectangle with the specified color using mode
  2598.             with opposite vertices defined by (x1, y1) and (x2, y2).  The
  2599.             vertices given do not need to be exactly the top left and
  2600.             bottom right.  They only have to reference opposite vertices
  2601.             of the rectangle.  Any portion of the rectangle that lies
  2602.             outside of the currently defined viewport will not be drawn.
  2603.  
  2604.             SEE ALSO
  2605.  
  2606.             DRWFILLBOX, DRWLINE, SETVIEW
  2607.  
  2608.             EXAMPLE
  2609.  
  2610.             /*
  2611.              * Places a box around the whole screen
  2612.              */
  2613.  
  2614.             #include <stdlib.h>
  2615.             #include <conio.h>
  2616.             #include "svgacc.h"
  2617.  
  2618.             void main(void)
  2619.             {
  2620.                int vmode;
  2621.  
  2622.                vmode = videomodeget();
  2623.                if ( !whichvga() )
  2624.                  exit(1);
  2625.                if ( whichmem() < 512)
  2626.                  exit(1);
  2627.                res640();
  2628.                drwbox (1,10,0,0,639,479);
  2629.                getch();
  2630.                videomodeset(vmode);
  2631.  
  2632.  
  2633.                                                                          41
  2634.  
  2635.  
  2636.  
  2637.  
  2638.  
  2639.                exit(0);
  2640.             }
  2641.  
  2642.  
  2643.  
  2644.  
  2645.  
  2646.  
  2647.  
  2648.  
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.  
  2656.  
  2657.  
  2658.  
  2659.  
  2660.  
  2661.  
  2662.  
  2663.  
  2664.  
  2665.  
  2666.  
  2667.  
  2668.  
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.                                                                          42
  2696.  
  2697.  
  2698.  
  2699.  
  2700.  
  2701.           DRWCIRARC
  2702.  
  2703.             PROTOTYPE
  2704.  
  2705.             extern void far drwcirarc (PixelMode mode, int colr, int
  2706.             xcenter, int ycenter, int radius, long startang, endaang)
  2707.  
  2708.             INPUT
  2709.  
  2710.             mode - pixel write mode (SET=1, XOR=2, OR=3, AND=4)
  2711.             colr - index to color in current palette
  2712.             xcenter, ycenter - location of center of circle
  2713.             radius - distance from center to edge of circle
  2714.             startang, endang - start and end angles in degrees
  2715.  
  2716.             OUTPUT
  2717.  
  2718.             no value returned
  2719.  
  2720.             USAGE
  2721.  
  2722.             DRWCIRARC draws a circular arc of the specified color and mode
  2723.             with the center located at (xcenter, ycenter), radius of
  2724.             radius, starting at the angle specified by startang and ending
  2725.             at the angle specified by endang.  All values of xcenter,
  2726.             ycenter, radius, startang, and endang are valid.  However,
  2727.             startang must be less than endang.  Any portion of the arc
  2728.             that lies outside of the currently defined viewport will not
  2729.             be drawn.
  2730.  
  2731.             SEE ALSO
  2732.  
  2733.             DRWCIRCLE, DRWELLARC
  2734.  
  2735.             EXAMPLE
  2736.  
  2737.             /*
  2738.              * draws some circular arcs
  2739.              */
  2740.  
  2741.             #include <stdlib.h>
  2742.             #include <conio.h>
  2743.             #include "svgacc.h"
  2744.  
  2745.             void main(void)
  2746.             {
  2747.                int i,r,sang;
  2748.  
  2749.                if ( !whichvga() )
  2750.                     exit(1);
  2751.                 if ( !res640() )
  2752.                  exit(1);
  2753.  
  2754.                for(i=0;i<=60;i++)
  2755.  
  2756.  
  2757.                                                                          43
  2758.  
  2759.  
  2760.  
  2761.  
  2762.  
  2763.                {
  2764.                  r=i*5;
  2765.                  sang=i*6;
  2766.                  drwcirarc (SET,10,maxx/2,maxy/2,r,sang,360);
  2767.                }
  2768.                getch();
  2769.                restext();
  2770.                exit(0);
  2771.             }
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797.  
  2798.  
  2799.  
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817.  
  2818.  
  2819.                                                                          44
  2820.  
  2821.  
  2822.  
  2823.  
  2824.  
  2825.           DRWCIRCLE
  2826.  
  2827.             PROTOTYPE
  2828.  
  2829.             extern void far drwcircle (PixelMode mode, int colr, int
  2830.             xcenter, int ycenter, int radius)
  2831.  
  2832.             INPUT
  2833.  
  2834.             mode - pixel write mode
  2835.             colr - index to color in current palette
  2836.             xcenter, ycenter - location of center of circle
  2837.             radius - distance from center to edge of circle
  2838.  
  2839.             OUTPUT
  2840.  
  2841.             no value returned
  2842.  
  2843.             USAGE
  2844.  
  2845.             DRWCIRCLE draws a circle of the specified color using mode
  2846.             with the center located at (xcenter, ycenter) and a radius of
  2847.             radius.  All values of xcenter, ycenter and radius are valid.
  2848.             Any portion of the circle that lies outside of the currently
  2849.             defined viewport will not be drawn.
  2850.  
  2851.             SEE ALSO
  2852.  
  2853.             DRWCIRARC, DRWELLIPSE, DRWFILLCIRCLE, SETVIEW
  2854.  
  2855.             EXAMPLE
  2856.  
  2857.             /*
  2858.              * Places a circle at the center of the screen
  2859.              */
  2860.  
  2861.             #include <stdlib.h>
  2862.             #include <conio.h>
  2863.             #include "svgacc.h"
  2864.  
  2865.             void main(void)
  2866.             {
  2867.                int vmode;
  2868.  
  2869.                vmode = videomodeget();
  2870.                if ( !whichvga() )
  2871.                  exit(1);
  2872.                if ( whichmem() < 512)
  2873.                  exit(1);
  2874.                res640();
  2875.                drwcircle (1,10,320,240,200);
  2876.                getch();
  2877.                videomodeset(vmode);
  2878.                exit(0);
  2879.  
  2880.  
  2881.                                                                          45
  2882.  
  2883.  
  2884.  
  2885.  
  2886.  
  2887.             }
  2888.  
  2889.  
  2890.  
  2891.  
  2892.  
  2893.  
  2894.  
  2895.  
  2896.  
  2897.  
  2898.  
  2899.  
  2900.  
  2901.  
  2902.  
  2903.  
  2904.  
  2905.  
  2906.  
  2907.  
  2908.  
  2909.  
  2910.  
  2911.  
  2912.  
  2913.  
  2914.  
  2915.  
  2916.  
  2917.  
  2918.  
  2919.  
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.  
  2927.  
  2928.  
  2929.  
  2930.  
  2931.  
  2932.  
  2933.  
  2934.  
  2935.  
  2936.  
  2937.  
  2938.  
  2939.  
  2940.  
  2941.  
  2942.  
  2943.                                                                          46
  2944.  
  2945.  
  2946.  
  2947.  
  2948.  
  2949.           DRWCUBICBEZIER
  2950.  
  2951.             PROTOTYPE
  2952.  
  2953.             extern void far drwcubicbezier (PixelMode mode, int colr,
  2954.             D2Point far* pon1, D2Point far* poff1, D2Point far* poff2,
  2955.             D2Point far* pon2)
  2956.  
  2957.             INPUT
  2958.  
  2959.             mode - pixel write mode (SET=1, XOR=2, OR=3, AND=4)
  2960.             colr - index to color in current palette
  2961.             pon1 - D2Point pointer to the start point
  2962.             poff1 - D2Point pointer to the first control point
  2963.             poff2 - D2Point pointer to the second control point
  2964.             pon2 - D2Point pointer to the end point
  2965.  
  2966.             OUTPUT
  2967.  
  2968.             no value returned
  2969.  
  2970.             USAGE
  2971.  
  2972.             DRWCUBICBEZIER draws a standard cubic Bezier curve connecting
  2973.             the points pon1 and pon2 using the specified mode and color.
  2974.             The off-curve control points are poff1 and poff2.  A technical
  2975.             description of cubic Bezier curves is beyond the scope of this
  2976.             manual.  However, most advanced computer graphics texts
  2977.             contain discussions on this topic.
  2978.  
  2979.             SEE ALSO
  2980.  
  2981.             DRWCIRARC, DRWELLARC
  2982.  
  2983.             EXAMPLE
  2984.  
  2985.             /*
  2986.              * Places cubic bezier curve at the center of the screen
  2987.              */
  2988.  
  2989.             #include <conio.h>
  2990.             #include <stdio.h>
  2991.             #include <stdlib.h>
  2992.             #include "svgacc.h"
  2993.  
  2994.             void main(void)
  2995.             {
  2996.                D2Point work[4] = { {260, 240}, {310, 360}, {330, 120},
  2997.             {380, 240} };
  2998.                if(!whichvga()) {
  2999.                  printf("no id vga\n");
  3000.                  exit(1);
  3001.                }
  3002.                res640();
  3003.  
  3004.  
  3005.                                                                          47
  3006.  
  3007.  
  3008.  
  3009.  
  3010.  
  3011.                drwcircle(SET,12,work[0].x,work[0].y,2);
  3012.                drwcircle(SET,12,work[1].x,work[1].y,2);
  3013.                drwcircle(SET,12,work[2].x,work[2].y,2);
  3014.                drwcircle(SET,12,work[3].x,work[3].y,2);
  3015.                drwcubicbezier(SET,15,&work[0],&work[1],&work[2],&work[3]);
  3016.  
  3017.                while(!kbhit());
  3018.                getch();
  3019.                restext();
  3020.             }
  3021.  
  3022.  
  3023.  
  3024.  
  3025.  
  3026.  
  3027.  
  3028.  
  3029.  
  3030.  
  3031.  
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037.  
  3038.  
  3039.  
  3040.  
  3041.  
  3042.  
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.  
  3063.  
  3064.  
  3065.  
  3066.  
  3067.                                                                          48
  3068.  
  3069.  
  3070.  
  3071.  
  3072.  
  3073.           DRWELLARC
  3074.  
  3075.             PROTOTYPE
  3076.  
  3077.             extern void far drwellarc (PixelMode mode, int colr, int
  3078.             xcenter, int ycenter, int radiusx, int radiusy, long startang,
  3079.             long endaang)
  3080.  
  3081.             INPUT
  3082.  
  3083.             mode - pixel write mode (SET=1, XOR=2, OR=3, AND=4)
  3084.             color - index to color in current palette
  3085.             xcenter, ycenter - location of center of ellipse
  3086.             radiusx - radius parallel to X axis
  3087.             radiusy - radius parallel to Y axis
  3088.             startang, endang - start and end angles in degrees
  3089.  
  3090.             OUTPUT
  3091.  
  3092.             no value returned
  3093.  
  3094.             USAGE
  3095.  
  3096.             DRWELLARC draws an elliptical arc of the specified color and
  3097.             mode with the center located at (xcenter, ycenter).  The
  3098.             radius in the horizontal direction is raduisx and the radius
  3099.             in the vertical direction is radiusy.  The starting angle is
  3100.             specified by startang and ends at the angle specified by
  3101.             endang.  All values of xcenter, ycenter, radiusx, radiusy,
  3102.             startang and endang are valid.  However, startang must be less
  3103.             than endang.  Any portion of the arc that lies outside of the
  3104.             currently defined viewport will not be drawn.
  3105.  
  3106.             SEE ALSO
  3107.  
  3108.             DRWCIRARC, DRWELLIPSE
  3109.  
  3110.             EXAMPLE
  3111.  
  3112.             /*
  3113.              * draws some ellipital arcs
  3114.              */
  3115.  
  3116.             #include <stdlib.h>
  3117.             #include <conio.h>
  3118.             #include "svgacc.h"
  3119.  
  3120.             void main(void)
  3121.             {
  3122.                int i,rx,ry,sang;
  3123.  
  3124.                if ( !whichvga() )
  3125.                     exit(1);
  3126.                 if ( !res640() )
  3127.  
  3128.  
  3129.                                                                          49
  3130.  
  3131.  
  3132.  
  3133.  
  3134.  
  3135.                  exit(1);
  3136.  
  3137.                for(i=0;i<=60;i++)
  3138.                {
  3139.                  rx=i*5;
  3140.                  ry=i*3;
  3141.                  sang=i*6;
  3142.                  drwellarc (SET,10,maxx/2,maxy/2,rx,ry,sang,360);
  3143.                }
  3144.                getch();
  3145.                restext();
  3146.                exit(0);
  3147.             }
  3148.  
  3149.  
  3150.  
  3151.  
  3152.  
  3153.  
  3154.  
  3155.  
  3156.  
  3157.  
  3158.  
  3159.  
  3160.  
  3161.  
  3162.  
  3163.  
  3164.  
  3165.  
  3166.  
  3167.  
  3168.  
  3169.  
  3170.  
  3171.  
  3172.  
  3173.  
  3174.  
  3175.  
  3176.  
  3177.  
  3178.  
  3179.  
  3180.  
  3181.  
  3182.  
  3183.  
  3184.  
  3185.  
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.                                                                          50
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.           DRWELLIPSE
  3198.  
  3199.             PROTOTYPE
  3200.  
  3201.             extern void far drwellipse (PixelMode mode, int colr, int
  3202.             xcenter, int ycenter, int radiusx, int radiusy)
  3203.  
  3204.             INPUT
  3205.  
  3206.             mode - pixel write mode
  3207.             colr - index to color in current palette
  3208.             xcenter, ycenter - location of center of ellipse
  3209.             radiusx - radius parallel to X axis
  3210.             radiusy - radius parallel to Y axis
  3211.  
  3212.             OUTPUT
  3213.  
  3214.             no value returned
  3215.  
  3216.             USAGE
  3217.  
  3218.             DRWELLIPSE draws an ellipse of the specified color using mode
  3219.             with the center defined by (xcenter, ycenter).  The radius in
  3220.             the horizontal direction is raduisx and the radius in the
  3221.             vertical direction is radiusy.  All values of xcenter,
  3222.             ycenter, radiusx and radiusy are valid.  Any portion of the
  3223.             ellipse that lies outside of the currently defined viewport
  3224.             will not be drawn.
  3225.  
  3226.             SEE ALSO
  3227.  
  3228.             DRWCIRCLE, DRWELLARC, DRWFILLELLIPSE, SETVIEW
  3229.  
  3230.             EXAMPLE
  3231.  
  3232.             /*
  3233.              * Places an ellipse at the center of the screen
  3234.              */
  3235.  
  3236.             #include <stdlib.h>
  3237.             #include <conio.h>
  3238.             #include "svgacc.h"
  3239.  
  3240.             void main(void)
  3241.             {
  3242.                int vmode;
  3243.  
  3244.                vmode = videomodeget();
  3245.                if ( !whichvga() )
  3246.                  exit(1);
  3247.                if ( whichmem() < 512)
  3248.                  exit(1);
  3249.                res640();
  3250.                drwellipse (1,10,320,240,318,238);
  3251.  
  3252.  
  3253.                                                                          51
  3254.  
  3255.  
  3256.  
  3257.  
  3258.  
  3259.                getch();
  3260.                videomodeset(vmode);
  3261.                exit(0);
  3262.             }
  3263.  
  3264.  
  3265.  
  3266.  
  3267.  
  3268.  
  3269.  
  3270.  
  3271.  
  3272.  
  3273.  
  3274.  
  3275.  
  3276.  
  3277.  
  3278.  
  3279.  
  3280.  
  3281.  
  3282.  
  3283.  
  3284.  
  3285.  
  3286.  
  3287.  
  3288.  
  3289.  
  3290.  
  3291.  
  3292.  
  3293.  
  3294.  
  3295.  
  3296.  
  3297.  
  3298.  
  3299.  
  3300.  
  3301.  
  3302.  
  3303.  
  3304.  
  3305.  
  3306.  
  3307.  
  3308.  
  3309.  
  3310.  
  3311.  
  3312.  
  3313.  
  3314.  
  3315.                                                                          52
  3316.  
  3317.  
  3318.  
  3319.  
  3320.  
  3321.           DRWFILLBOX
  3322.  
  3323.             PROTOTYPE
  3324.  
  3325.             extern void far drwfillbox (PixelMode mode, int colr, int x1,
  3326.             int y1, int x2, int y2)
  3327.  
  3328.             INPUT
  3329.  
  3330.             mode - pixel write mode
  3331.             colr - index to color in current palette
  3332.             x1, y1 - location of top left corner
  3333.             x2, y2 - location of bottom right corner
  3334.  
  3335.             OUTPUT
  3336.  
  3337.             no value returned
  3338.  
  3339.             USAGE
  3340.  
  3341.             DRWFILLBOX draws a solid rectangle with the specified color
  3342.             using mode with opposite vertices defined by (x1, y1) and (x2,
  3343.             y2).  The vertices given do not need to be exactly the top
  3344.             left and bottom right.  They only have to reference opposite
  3345.             vertices of the rectangle.  Any portion of the rectangle that
  3346.             lies outside of the currently defined viewport will not be
  3347.             drawn.
  3348.  
  3349.             SEE ALSO
  3350.  
  3351.             DRWBOX, DRWLINE, FILLCONVEXPOLY, FILLPOLY, SETVIEW
  3352.  
  3353.             EXAMPLE
  3354.  
  3355.             /*
  3356.              * Places a filled box in the center of the screen
  3357.              */
  3358.  
  3359.             #include <stdlib.h>
  3360.             #include <conio.h>
  3361.             #include "svgacc.h"
  3362.  
  3363.             void main(void)
  3364.             {
  3365.                int vmode;
  3366.                vmode = videomodeget();
  3367.                if ( !whichvga() )
  3368.                  exit(1);
  3369.                if ( whichmem() < 512)
  3370.                     exit(1);
  3371.                if ( !res640() )
  3372.                     exit(1);
  3373.                drwfillbox (1,10,270,190,370,290);
  3374.                getch();
  3375.  
  3376.  
  3377.                                                                          53
  3378.  
  3379.  
  3380.  
  3381.  
  3382.  
  3383.                videomodeset(vmode);
  3384.                exit(0);
  3385.             }
  3386.  
  3387.  
  3388.  
  3389.  
  3390.  
  3391.  
  3392.  
  3393.  
  3394.  
  3395.  
  3396.  
  3397.  
  3398.  
  3399.  
  3400.  
  3401.  
  3402.  
  3403.  
  3404.  
  3405.  
  3406.  
  3407.  
  3408.  
  3409.  
  3410.  
  3411.  
  3412.  
  3413.  
  3414.  
  3415.  
  3416.  
  3417.  
  3418.  
  3419.  
  3420.  
  3421.  
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433.  
  3434.  
  3435.  
  3436.  
  3437.  
  3438.  
  3439.                                                                          54
  3440.  
  3441.  
  3442.  
  3443.  
  3444.  
  3445.           DRWFILLCIRCLE
  3446.  
  3447.             PROTOTYPE
  3448.  
  3449.             extern void far drwfillcircle (PixelMode mode, int colr, int
  3450.             xcenter, int ycenter, int radius)
  3451.  
  3452.             INPUT
  3453.  
  3454.             mode - pixel write mode
  3455.             colr - index to color in current palette
  3456.             xcenter, ycenter - location of center of circle
  3457.             radius - distance from center to edge of circle
  3458.  
  3459.             OUTPUT
  3460.  
  3461.             no value returned
  3462.  
  3463.             USAGE
  3464.  
  3465.             DRWFILLCIRCLE draws a solid circle of the specified color
  3466.             using mode with the center located at (xcenter, ycenter) and a
  3467.             radius of radius.  All values of xcenter, ycenter and radius
  3468.             are valid.  Any portion of the circle that lies outside of the
  3469.             currently defined viewport will not be drawn.
  3470.  
  3471.             SEE ALSO
  3472.  
  3473.             DRWCIRCLE, SETVIEW
  3474.  
  3475.             EXAMPLE
  3476.  
  3477.             /*
  3478.              * Places a filled circle at the center of the screen
  3479.              */
  3480.  
  3481.             #include <stdlib.h>
  3482.             #include <conio.h>
  3483.             #include "svgacc.h"
  3484.  
  3485.             void main(void)
  3486.             {
  3487.                int vmode;
  3488.                vmode = videomodeget();
  3489.                if ( !whichvga() )
  3490.                  exit(1);
  3491.                if ( whichmem() < 512)
  3492.                  exit(1);
  3493.                if ( !res640() )
  3494.                  exit(1);
  3495.                drwfillcircle (1,10,320,240,100);
  3496.                getch();
  3497.                videomodeset(vmode);
  3498.                exit(0);
  3499.  
  3500.  
  3501.                                                                          55
  3502.  
  3503.  
  3504.  
  3505.  
  3506.  
  3507.             }
  3508.  
  3509.  
  3510.  
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.  
  3518.  
  3519.  
  3520.  
  3521.  
  3522.  
  3523.  
  3524.  
  3525.  
  3526.  
  3527.  
  3528.  
  3529.  
  3530.  
  3531.  
  3532.  
  3533.  
  3534.  
  3535.  
  3536.  
  3537.  
  3538.  
  3539.  
  3540.  
  3541.  
  3542.  
  3543.  
  3544.  
  3545.  
  3546.  
  3547.  
  3548.  
  3549.  
  3550.  
  3551.  
  3552.  
  3553.  
  3554.  
  3555.  
  3556.  
  3557.  
  3558.  
  3559.  
  3560.  
  3561.  
  3562.  
  3563.                                                                          56
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.           DRWFILLELLIPSE
  3570.  
  3571.             PROTOTYPE
  3572.  
  3573.             extern void far drwfillellipse (PixelMode mode, int colr, int
  3574.             xcenter, int ycenter, int radiusx, int radiusy)
  3575.  
  3576.             INPUT
  3577.  
  3578.             mode - pixel write mode
  3579.             colr - index to color in current palette
  3580.             xcenter, ycenter - location of center of ellipse
  3581.             radiusx - radius parallel to X axis
  3582.             radiusy - radius parallel to Y axis
  3583.  
  3584.             OUTPUT
  3585.  
  3586.             no value returned
  3587.  
  3588.             USAGE
  3589.  
  3590.             DRWFILLELLIPSE draws an ellipse of the specified color using
  3591.             mode with the center defined by (xcenter, ycenter).  The
  3592.             radius in the horizontal direction is raduisx and the radius
  3593.             in the vertical direction is radiusy.  All values of xcenter,
  3594.             ycenter, radiusx and radiusy are valid.  Any portion of the
  3595.             ellipse that lies outside of the currently defined viewport
  3596.             will not be drawn.
  3597.  
  3598.             SEE ALSO
  3599.  
  3600.             DRWELLIPSE, SETVIEW
  3601.  
  3602.             EXAMPLE
  3603.  
  3604.             /*
  3605.              * Places a filled ellipse at the center of the screen
  3606.              */
  3607.  
  3608.             #include <stdlib.h>
  3609.             #include <conio.h>
  3610.             #include "svgacc.h"
  3611.  
  3612.             void main(void)
  3613.             {
  3614.                int vmode;
  3615.                vmode = videomodeget();
  3616.                if ( !whichvga() )
  3617.                  exit(1);
  3618.                if ( whichmem() < 512)
  3619.                  exit(1);
  3620.                if ( !res640() )
  3621.                exit(1);
  3622.                drwfillellipse (1,10,320,240,218,138);
  3623.  
  3624.  
  3625.                                                                          57
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.                getch();
  3632.                videomodeset(vmode);
  3633.                exit(0);
  3634.             }
  3635.  
  3636.  
  3637.  
  3638.  
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.                                                                          58
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.           DRWLINE
  3694.  
  3695.             PROTOTYPE
  3696.  
  3697.             extern void far drwline (PixelMode mode, int colr, int x1, int
  3698.             y1, int x2, int y2)
  3699.  
  3700.             INPUT
  3701.  
  3702.             mode - pixel write mode
  3703.             colr - index to color in current palette
  3704.             x1, y1 - location of one endpoint of line
  3705.             x2, y2 - location of other endpoint of line
  3706.  
  3707.             OUTPUT
  3708.  
  3709.             no value returned
  3710.  
  3711.             USAGE
  3712.  
  3713.             DRWLINE draws a line of the specified color using mode with
  3714.             endpoints located at (x1, y1) And (x2, y2).  All values of x1,
  3715.             y1, x2 and y2 are valid.  Any portion of the line that lies
  3716.             outside of the currently defined viewport will not be drawn.
  3717.  
  3718.             SEE ALSO
  3719.  
  3720.             DRWALINE, DRWBOX, SETVIEW
  3721.  
  3722.             EXAMPLE
  3723.  
  3724.             /*
  3725.              * Draws a line from 0,0 to the center of the screen
  3726.              */
  3727.  
  3728.             #include <stdlib.h>
  3729.             #include <conio.h>
  3730.             #include "svgacc.h"
  3731.  
  3732.             void main(void)
  3733.             {
  3734.                int vmode;
  3735.                vmode = videomodeget();
  3736.                if ( !whichvga() )
  3737.                  exit(1);
  3738.                if ( whichmem() < 512)
  3739.                  exit(1);
  3740.                res640();
  3741.                drwline (1,10,0,0,320,240);
  3742.                getch();
  3743.                videomodeset(vmode);
  3744.                exit(0);
  3745.             }
  3746.  
  3747.  
  3748.  
  3749.                                                                          59
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.           DRWPOINT
  3756.  
  3757.             PROTOTYPE
  3758.  
  3759.             extern void far drwpoint (PixelMode mode, int colr, int x, int
  3760.             y)
  3761.  
  3762.             INPUT
  3763.  
  3764.             mode - pixel write mode
  3765.             colr - index to color in current palette
  3766.             x, y - location of pixel to write
  3767.  
  3768.             OUTPUT
  3769.  
  3770.             no value returned
  3771.  
  3772.             USAGE
  3773.  
  3774.             DRWPOINT draws a single point of the specified color using
  3775.             mode at (x, y).  All values of x and y are valid.  If the
  3776.             point (x, y) lies outside of the currently defined viewport,
  3777.             no drawing will take place.
  3778.  
  3779.             SEE ALSO
  3780.  
  3781.             GETPOINT, SETVIEW
  3782.  
  3783.             EXAMPLE
  3784.  
  3785.             /*
  3786.              * Draws a point at the center of the screen
  3787.              */
  3788.  
  3789.             #include <stdlib.h>
  3790.             #include <conio.h>
  3791.             #include "svgacc.h"
  3792.  
  3793.             void main(void)
  3794.             {
  3795.                int vmode;
  3796.  
  3797.                vmode = videomodeget();
  3798.                if ( !whichvga() )
  3799.                  exit(1);
  3800.                if ( whichmem() < 512)
  3801.                  exit(1);
  3802.                res640();
  3803.                drwpoint (1,10,320,240);
  3804.                getch();
  3805.                videomodeset(vmode);
  3806.                exit(0);
  3807.             }
  3808.  
  3809.  
  3810.  
  3811.                                                                          60
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.           DRWSTRING
  3818.  
  3819.             PROTOTYPE
  3820.  
  3821.             extern void far drwstring (PixelMode mode, int fcolr, int
  3822.             bcolr, const char far *strng, int x, int y)
  3823.  
  3824.             INPUT
  3825.  
  3826.             mode - pixel write mode
  3827.             fcolr - foreground index to color in current palette
  3828.             bcolr - background index to color in current palette
  3829.             strng - char pointer to string of ASCII characters to be drawn
  3830.             x, y - location of upper, left corner of block
  3831.  
  3832.             OUTPUT
  3833.  
  3834.             no value returned
  3835.  
  3836.             USAGE
  3837.  
  3838.             DRWSTRING takes the null terminated ASCII characters beginning
  3839.             at strng and creates a graphics block similar to the blocks
  3840.             used by blkget and blkput and places this block on the screen
  3841.             at the specified coordinates.  The characters are drawn with
  3842.             color fcolr using the current font and the background is color
  3843.             bcolr.  When mode 0, NO_ACTION, is used, the graphics block is
  3844.             created in memory, retrievable by GETLASTSTRING, but no text
  3845.             is actually drawn on the screen.  (Note: the system font is
  3846.             automatically installed when WHICHVGA is called.)
  3847.  
  3848.             SEE ALSO
  3849.  
  3850.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRINGDN, DRWSTRINGLT,
  3851.             DRWSTRINGRT, GETLASTSTRING
  3852.  
  3853.             EXAMPLE
  3854.  
  3855.             /*
  3856.              * Draws some normal text at the center of the screen
  3857.              */
  3858.             #include <stdlib.h>
  3859.             #include <conio.h>
  3860.             #include "svgacc.h"
  3861.  
  3862.             void main(void)
  3863.             {
  3864.                int vmode;
  3865.                char text[]="hello world";
  3866.  
  3867.                vmode = videomodeget();
  3868.                if ( !whichvga() || (whichmem() < 512))
  3869.                  exit(1);
  3870.                res640();
  3871.  
  3872.  
  3873.                                                                          61
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.                drwstring(1,10,0,text,320,240);
  3880.                getch();
  3881.                videomodeset(vmode);
  3882.                exit(0);
  3883.             }
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.  
  3895.  
  3896.  
  3897.  
  3898.  
  3899.  
  3900.  
  3901.  
  3902.  
  3903.  
  3904.  
  3905.  
  3906.  
  3907.  
  3908.  
  3909.  
  3910.  
  3911.  
  3912.  
  3913.  
  3914.  
  3915.  
  3916.  
  3917.  
  3918.  
  3919.  
  3920.  
  3921.  
  3922.  
  3923.  
  3924.  
  3925.  
  3926.  
  3927.  
  3928.  
  3929.  
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935.                                                                          62
  3936.  
  3937.  
  3938.  
  3939.  
  3940.  
  3941.           DRWSTRINGDN
  3942.  
  3943.             PROTOTYPE
  3944.  
  3945.             extern void far drwstringdn (PixelMode mode, int fcolr, int
  3946.             bcolr, const char far *strng, int x, int y)
  3947.  
  3948.             INPUT
  3949.  
  3950.             mode - pixel write mode
  3951.             fcolr - foreground index to color in current palette
  3952.             bcolr - background index to color in current palette
  3953.             strng - char pointer to string of ASCII characters to be drawn
  3954.             x, y - location of lower, right corner of block
  3955.  
  3956.             OUTPUT
  3957.  
  3958.             no value returned
  3959.  
  3960.             USAGE
  3961.  
  3962.             DRWSTRINGDN takes the null terminated ASCII characters
  3963.             beginning at strng and creates a graphics block similar to the
  3964.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  3965.             with color fcolr using the current font and the background is
  3966.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  3967.             block is created in memory retrievable by GETLASTSTRING, but
  3968.             no text is actually drawn on the screen.  (Note: the system
  3969.             font is automatically installed when WHICHVGA is called.)  The
  3970.             text is drawn upside down with x, y specifying the lower,
  3971.             right corner.  This corner corresponds to the upper, left
  3972.             corner when the text is oriented upright.
  3973.  
  3974.             SEE ALSO
  3975.  
  3976.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGLT,
  3977.             DRWSTRINGRT, GETLASTSTRING
  3978.  
  3979.             EXAMPLE
  3980.  
  3981.             /* Draws some text rotated by 180 degrees at the center of the
  3982.             screen */
  3983.             #include <stdlib.h>
  3984.             #include <conio.h>
  3985.             #include "svgacc.h"
  3986.  
  3987.             void main(void)
  3988.             {
  3989.                int vmode;
  3990.                char text[]="hello world";
  3991.  
  3992.                vmode = videomodeget();
  3993.                if ( !whichvga() || (whichmem() < 512))
  3994.                  exit(1);
  3995.  
  3996.  
  3997.                                                                          63
  3998.  
  3999.  
  4000.  
  4001.  
  4002.  
  4003.                res640();
  4004.                drwstringdn(1,10,0,text,320,240);
  4005.                getch();
  4006.                videomodeset(vmode);
  4007.                exit(0);
  4008.             }
  4009.  
  4010.  
  4011.  
  4012.  
  4013.  
  4014.  
  4015.  
  4016.  
  4017.  
  4018.  
  4019.  
  4020.  
  4021.  
  4022.  
  4023.  
  4024.  
  4025.  
  4026.  
  4027.  
  4028.  
  4029.  
  4030.  
  4031.  
  4032.  
  4033.  
  4034.  
  4035.  
  4036.  
  4037.  
  4038.  
  4039.  
  4040.  
  4041.  
  4042.  
  4043.  
  4044.  
  4045.  
  4046.  
  4047.  
  4048.  
  4049.  
  4050.  
  4051.  
  4052.  
  4053.  
  4054.  
  4055.  
  4056.  
  4057.  
  4058.  
  4059.                                                                          64
  4060.  
  4061.  
  4062.  
  4063.  
  4064.  
  4065.           DRWSTRINGLT
  4066.  
  4067.             PROTOTYPE
  4068.  
  4069.             extern void far drwstringlt (PixelMode mode, int fcolr, int
  4070.             bcolr, const char far *strng, int x, int y)
  4071.  
  4072.             INPUT
  4073.  
  4074.             mode - pixel write mode
  4075.             fcolr - foreground index to color in current palette
  4076.             bcolr - background index to color in current palette
  4077.             strng - char pointer to string of ASCII characters to be drawn
  4078.             x, y - location of lower, left corner of block
  4079.  
  4080.             OUTPUT
  4081.  
  4082.             no value returned
  4083.  
  4084.             USAGE
  4085.  
  4086.             DRWSTRINGLT takes the null terminated ASCII characters
  4087.             beginning at strng and creates a graphics block similar to the
  4088.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  4089.             with color fcolr using the current font and the background is
  4090.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  4091.             block is created in memory retrievable by GETLASTSTRING, but
  4092.             no text is actually drawn on the screen.  (Note: the system
  4093.             font is automatically installed when WHICHVGA is called.)  The
  4094.             text block is rotated 90 to the left with x, y specifying the
  4095.             lower, left corner.  This corner corresponds to the upper,
  4096.             left corner when the text is oriented upright.
  4097.  
  4098.             SEE ALSO
  4099.  
  4100.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGDN,
  4101.             DRWSTRINGRT, GETLASTSTRING
  4102.  
  4103.             EXAMPLE
  4104.  
  4105.             /* Draws some text rotated 90 degrees to the left at center of
  4106.             screen */
  4107.             #include <stdlib.h>
  4108.             #include <conio.h>
  4109.             #include "svgacc.h"
  4110.  
  4111.             void main(void)
  4112.             {
  4113.                int vmode;
  4114.                char text[]="hello world";
  4115.  
  4116.                vmode = videomodeget();
  4117.                if ( !whichvga() || (whichmem() < 512))
  4118.                  exit(1);
  4119.  
  4120.  
  4121.                                                                          65
  4122.  
  4123.  
  4124.  
  4125.  
  4126.  
  4127.                res640();
  4128.                drwstringlt(1,10,0,text,320,240);
  4129.                getch();
  4130.                videomodeset(vmode);
  4131.                exit(0);
  4132.             }
  4133.  
  4134.  
  4135.  
  4136.  
  4137.  
  4138.  
  4139.  
  4140.  
  4141.  
  4142.  
  4143.  
  4144.  
  4145.  
  4146.  
  4147.  
  4148.  
  4149.  
  4150.  
  4151.  
  4152.  
  4153.  
  4154.  
  4155.  
  4156.  
  4157.  
  4158.  
  4159.  
  4160.  
  4161.  
  4162.  
  4163.  
  4164.  
  4165.  
  4166.  
  4167.  
  4168.  
  4169.  
  4170.  
  4171.  
  4172.  
  4173.  
  4174.  
  4175.  
  4176.  
  4177.  
  4178.  
  4179.  
  4180.  
  4181.  
  4182.  
  4183.                                                                          66
  4184.  
  4185.  
  4186.  
  4187.  
  4188.  
  4189.           DRWSTRINGRT
  4190.  
  4191.             PROTOTYPE
  4192.  
  4193.             extern void far drwstringrt (PixelMode mode, int fcolr, int
  4194.             bcolr, const char far *strng, int x, int y)
  4195.  
  4196.             INPUT
  4197.  
  4198.             mode - pixel write mode
  4199.             fcolr - foreground index to color in current palette
  4200.             bcolr - background index to color in current palette
  4201.             strng - char pointer to string of ASCII characters to be drawn
  4202.             x, y - location of upper, right corner of block
  4203.  
  4204.             OUTPUT
  4205.  
  4206.             no value returned
  4207.  
  4208.             USAGE
  4209.  
  4210.             DRWSTRINGRT takes the null terminated ASCII characters
  4211.             beginning at strng and creates a graphics block similar to the
  4212.             blocks used by BLKGET and BLKPUT.  The characters are drawn
  4213.             with color fcolr using the current font and the background is
  4214.             color bcolr.  When mode 0, NO_ACTION, is used, the graphics
  4215.             block is created in memory retrievable by GETLASTSTRING, but
  4216.             no text is actually drawn on the screen.  (Note: the system
  4217.             font is automatically installed when WHICHVGA is called.)  The
  4218.             text block is rotated 90 to the right with x, y specifying the
  4219.             upper, right corner.  This corner corresponds to the upper,
  4220.             left corner if the text is oriented upright.
  4221.  
  4222.             SEE ALSO
  4223.  
  4224.             FONTSET, FONTGETINFO, FONTSYSTEM, DRWSTRING, DRWSTRINGDN,
  4225.             DRWSTRINGLT, GETLASTSTRING
  4226.  
  4227.             EXAMPLE
  4228.  
  4229.             /* Draws text rotated 90 degrees to the right at center of
  4230.             screen */
  4231.             #include <stdlib.h>
  4232.             #include <conio.h>
  4233.             #include "svgacc.h"
  4234.  
  4235.             void main(void)
  4236.             {
  4237.                int vmode;
  4238.                char text[]="hello world";
  4239.  
  4240.                vmode = videomodeget();
  4241.                if ( !whichvga() || (whichmem() < 512))
  4242.                  exit(1);
  4243.  
  4244.  
  4245.                                                                          67
  4246.  
  4247.  
  4248.  
  4249.  
  4250.  
  4251.                res640();
  4252.                drwstringrt(1,10,0,text,320,240);
  4253.                getch();
  4254.                videomodeset(vmode);
  4255.                exit(0);
  4256.             }
  4257.  
  4258.  
  4259.  
  4260.  
  4261.  
  4262.  
  4263.  
  4264.  
  4265.  
  4266.  
  4267.  
  4268.  
  4269.  
  4270.  
  4271.  
  4272.  
  4273.  
  4274.  
  4275.  
  4276.  
  4277.  
  4278.  
  4279.  
  4280.  
  4281.  
  4282.  
  4283.  
  4284.  
  4285.  
  4286.  
  4287.  
  4288.  
  4289.  
  4290.  
  4291.  
  4292.  
  4293.  
  4294.  
  4295.  
  4296.  
  4297.  
  4298.  
  4299.  
  4300.  
  4301.  
  4302.  
  4303.  
  4304.  
  4305.  
  4306.  
  4307.                                                                          68
  4308.  
  4309.  
  4310.  
  4311.  
  4312.  
  4313.           FILLAREA
  4314.  
  4315.             PROTOTYPE
  4316.  
  4317.             extern void far fillarea (int xseed, int yseed, int
  4318.             bordercolr, int fillcolr)
  4319.  
  4320.             INPUT
  4321.  
  4322.             xseed, yseed - seed location to start fill
  4323.             bordercolr - index to color in current palette at which
  4324.             filling stops
  4325.             fillcolr - index to color in current palette to fill within
  4326.             the border
  4327.  
  4328.             OUTPUT
  4329.  
  4330.             no value returned
  4331.  
  4332.             USAGE
  4333.  
  4334.             FILLAREA fills a region with a new color specified by
  4335.             fillcolr.  The region is defined by any line or curve of the
  4336.             color bordercolr or fillcolr or by the edge of the viewport.
  4337.             All graphics within the region are lost and covered with the
  4338.             fillcolr.  The border is not effected.
  4339.  
  4340.             SEE ALSO
  4341.  
  4342.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLCOLOR,
  4343.             FILLCONVEXPOLY, FILLPOLY, FILLPAGE, FILLSCREEN, FILLVIEW,
  4344.             SETVIEW
  4345.  
  4346.             EXAMPLE
  4347.  
  4348.             /*
  4349.              * fills a box with some color
  4350.              */
  4351.  
  4352.             #include <stdlib.h>
  4353.             #include <conio.h>
  4354.             #include "svgacc.h"
  4355.  
  4356.             void main(void)
  4357.             {
  4358.                int vmode;
  4359.  
  4360.                vmode = videomodeget();
  4361.                if ( !whichvga() )
  4362.                  exit(1);
  4363.                if ( whichmem() < 512)
  4364.                  exit(1);
  4365.                res640();
  4366.                drwbox(1,10,0,0,100,100);
  4367.  
  4368.  
  4369.                                                                          69
  4370.  
  4371.  
  4372.  
  4373.  
  4374.  
  4375.                fillarea(1,1,10,7);
  4376.                getch();
  4377.                videomodeset(vmode);
  4378.                exit(0);
  4379.             }
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.  
  4386.  
  4387.  
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.  
  4394.  
  4395.  
  4396.  
  4397.  
  4398.  
  4399.  
  4400.  
  4401.  
  4402.  
  4403.  
  4404.  
  4405.  
  4406.  
  4407.  
  4408.  
  4409.  
  4410.  
  4411.  
  4412.  
  4413.  
  4414.  
  4415.  
  4416.  
  4417.  
  4418.  
  4419.  
  4420.  
  4421.  
  4422.  
  4423.  
  4424.  
  4425.  
  4426.  
  4427.  
  4428.  
  4429.  
  4430.  
  4431.                                                                          70
  4432.  
  4433.  
  4434.  
  4435.  
  4436.  
  4437.           FILLCOLOR
  4438.  
  4439.             PROTOTYPE
  4440.  
  4441.             extern void far fillcolor (int xseed, int yseed, int oldcolr,
  4442.             int newcolr)
  4443.  
  4444.             INPUT
  4445.  
  4446.             xseed, yseed - seed location to start fill
  4447.             oldcolr - index to color in current palette to change
  4448.             newcolr - index to color in current palette to replace oldcolr
  4449.  
  4450.             OUTPUT
  4451.  
  4452.             no value returned
  4453.  
  4454.             USAGE
  4455.  
  4456.             FILLCOLOR replaces every existence of oldcolr with newcolr
  4457.             within a region.  The region is defined as any pixel of
  4458.             oldcolr which has a path of pixels of oldcolr or newcolr with
  4459.             sides touching back to the seed point, (xseed, yseed).
  4460.             Therefore, only pixels of oldcolr are modified and no other
  4461.             information is changed.
  4462.  
  4463.             SEE ALSO
  4464.  
  4465.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4466.             FILLCONVEXPOLY, FILLPOLY, FILLPAGE, FILLSCREEN, FILLVIEW,
  4467.             SETVIEW
  4468.  
  4469.             EXAMPLE
  4470.  
  4471.             /*
  4472.              * replaces the black color with a new color
  4473.              */
  4474.  
  4475.             #include <stdlib.h>
  4476.             #include <conio.h>
  4477.             #include "svgacc.h"
  4478.  
  4479.             void main(void)
  4480.             {
  4481.                int vmode;
  4482.  
  4483.                vmode = videomodeget();
  4484.                if ( !whichvga() )
  4485.                  exit(1);
  4486.                if ( whichmem() < 512)
  4487.                  exit(1);
  4488.                res640();
  4489.                drwbox(1,10,0,0,100,100);
  4490.                drwbox(1,12,20,20,80,80);
  4491.  
  4492.  
  4493.                                                                          71
  4494.  
  4495.  
  4496.  
  4497.  
  4498.  
  4499.                fillcolor(1,1,0,7);
  4500.                getch();
  4501.                videomodeset(vmode);
  4502.                exit(0);
  4503.             }
  4504.  
  4505.  
  4506.  
  4507.  
  4508.  
  4509.  
  4510.  
  4511.  
  4512.  
  4513.  
  4514.  
  4515.  
  4516.  
  4517.  
  4518.  
  4519.  
  4520.  
  4521.  
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.  
  4537.  
  4538.  
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.  
  4545.  
  4546.  
  4547.  
  4548.  
  4549.  
  4550.  
  4551.  
  4552.  
  4553.  
  4554.  
  4555.                                                                          72
  4556.  
  4557.  
  4558.  
  4559.  
  4560.  
  4561.           FILLCONVEXPOLY
  4562.  
  4563.             PROTOTYPE
  4564.  
  4565.             extern void far fillconvexpoly (int polycolr, int numpoints,
  4566.             D2Point far* pointarray)
  4567.  
  4568.             INPUT
  4569.  
  4570.             polycolor - index to color in current palette
  4571.             numpoints - number of points in PointArray
  4572.             pointarray - D2Point pointer to array containing polygon
  4573.             points
  4574.  
  4575.             OUTPUT
  4576.  
  4577.             no value returned
  4578.  
  4579.             USAGE
  4580.  
  4581.             FILLCONVEXPOLY draws a solid polygon outlined by the points
  4582.             given in pointarray.  The points are expected to be
  4583.             consecutive and the resulting polygon should be convex (ie.
  4584.             the polygon should not curve in on itself like a kidney bean).
  4585.             The function also assumes that the last point in the array
  4586.             connects to the first.
  4587.  
  4588.             SEE ALSO
  4589.  
  4590.             D3PROJECT, DRWFILLBOX, FILLAREA, FILLCOLOR, FILLPAGE,
  4591.             FILLPOLY, FILLSCREEN, FILLVIEW
  4592.  
  4593.             EXAMPLE
  4594.  
  4595.             /*
  4596.             * Show fillconvexpoly
  4597.             */
  4598.  
  4599.             #include <stdlib.h>
  4600.             #include <math.h>
  4601.             #include <conio.h>
  4602.             #include "svgacc.h"
  4603.             #define randnum(size) (rand() % (int)(size))
  4604.  
  4605.             D2Point tri[3];
  4606.  
  4607.             void main(void)
  4608.             {
  4609.                int vmode,colr,i;
  4610.  
  4611.                vmode = videomodeget();
  4612.                if ( !whichvga() )
  4613.                  exit(1);
  4614.                if ( whichmem() < 512)
  4615.  
  4616.  
  4617.                                                                          73
  4618.  
  4619.  
  4620.  
  4621.  
  4622.  
  4623.                  exit(1);
  4624.                if ( !res640() )
  4625.                  exit(1);
  4626.  
  4627.                for(i=0;i<99;i++) {
  4628.                  tri[0].x = randnum(maxx);
  4629.                  tri[0].y = randnum(maxy);
  4630.                  tri[1].x = randnum(maxx);
  4631.                  tri[1].y = randnum(maxy);
  4632.                  tri[2].x = randnum(maxx);
  4633.                  tri[2].y = randnum(maxy);
  4634.                  colr = randnum(15);
  4635.                  fillconvexpoly(colr,3,tri);
  4636.                }
  4637.  
  4638.                getch();
  4639.                videomodeset(vmode);
  4640.                exit(0);
  4641.             }
  4642.  
  4643.  
  4644.  
  4645.  
  4646.  
  4647.  
  4648.  
  4649.  
  4650.  
  4651.  
  4652.  
  4653.  
  4654.  
  4655.  
  4656.  
  4657.  
  4658.  
  4659.  
  4660.  
  4661.  
  4662.  
  4663.  
  4664.  
  4665.  
  4666.  
  4667.  
  4668.  
  4669.  
  4670.  
  4671.  
  4672.  
  4673.  
  4674.  
  4675.  
  4676.  
  4677.  
  4678.  
  4679.                                                                          74
  4680.  
  4681.  
  4682.  
  4683.  
  4684.  
  4685.           FILLPAGE
  4686.  
  4687.             PROTOTYPE
  4688.  
  4689.             extern void far fillpage (int colr)
  4690.  
  4691.             INPUT
  4692.  
  4693.             colr - index to color in current palette
  4694.  
  4695.             OUTPUT
  4696.  
  4697.             no value is returned
  4698.  
  4699.             USAGE
  4700.  
  4701.             FILLPAGE clears the currently active page with the specified
  4702.             color.  All information on the page is lost.  (Note, a faster
  4703.             method to clear the page is to call any of the RES###
  4704.             functions.  These reset the graphics screen and automatically
  4705.             clear it to color index zero as well as reset the default
  4706.             palette.)
  4707.  
  4708.             SEE ALSO
  4709.  
  4710.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4711.             FILLCOLOR, FILLCONVEXPOLY, FILLPOLY, FILLSCREEN, FILLVIEW
  4712.  
  4713.             EXAMPLE
  4714.  
  4715.             /*
  4716.              * fill the page with a color
  4717.              */
  4718.  
  4719.             #include <stdlib.h>
  4720.             #include <conio.h>
  4721.             #include "svgacc.h"
  4722.  
  4723.             void main(void)
  4724.             {
  4725.                int vmode;
  4726.  
  4727.                vmode = videomodeget();
  4728.                if ( !whichvga() )
  4729.                  exit(1);
  4730.                if ( whichmem() < 512)
  4731.                  exit(1);
  4732.                res640();
  4733.                fillpage(10);
  4734.                getch();
  4735.                videomodeset(vmode);
  4736.                exit(0);
  4737.             }
  4738.  
  4739.  
  4740.  
  4741.                                                                          75
  4742.  
  4743.  
  4744.  
  4745.  
  4746.  
  4747.           FILLPOLY
  4748.  
  4749.             PROTOTYPE
  4750.  
  4751.             extern void far fillpoly (int polycolr, int numpoints, D2Point
  4752.             far *pointarray)
  4753.  
  4754.             INPUT
  4755.  
  4756.             polycolor - index to color in current palette
  4757.             numpoints - number of points in PointArray
  4758.             pointarray - D2Point pointer to array containing polygon
  4759.             points
  4760.  
  4761.             OUTPUT
  4762.  
  4763.             no value returned
  4764.  
  4765.             USAGE
  4766.  
  4767.             FILLPOLY draws a solid polygon outlined by the points given in
  4768.             pointarray.  The points are expected to be consecutive.
  4769.             However, there are no restrictions on the relative locations
  4770.             of the points.  The polygon may curve in on itself or have
  4771.             crossed lines.  The function also assumes that the last point
  4772.             in the array connects to the first.  FILLPOLY can be used
  4773.             interchangeably with FILLCONVEXPOLY, although FILLPOLY is
  4774.             slightly slower.
  4775.  
  4776.             Special thanks to Eric Jorgensen for providing the algorithm
  4777.             which formed the basis for FILLPOLY.
  4778.  
  4779.             SEE ALSO
  4780.  
  4781.             D3PROJECT, DRWFILLBOX, FILLAREA, FILLCOLOR, FILLCONVEXPOLY,
  4782.             FILLPAGE, FILLSCREEN, FILLVIEW
  4783.  
  4784.             EXAMPLE
  4785.  
  4786.             /*
  4787.             * Show fillpoly
  4788.             */
  4789.  
  4790.             #include <stdlib.h>
  4791.             #include <math.h>
  4792.             #include <conio.h>
  4793.             #include "svgacc.h"
  4794.             #define randnum(size) (rand() % (int)(size))
  4795.  
  4796.             void main(void)
  4797.             {
  4798.                D2Point star[5];
  4799.  
  4800.                if ( !whichvga() )
  4801.  
  4802.  
  4803.                                                                          76
  4804.  
  4805.  
  4806.  
  4807.  
  4808.  
  4809.                  exit(1);
  4810.                if ( whichmem() < 512)
  4811.                exit(1);
  4812.                if ( !res640() )
  4813.                exit(1);
  4814.  
  4815.                star[0].x = 320;
  4816.                star[0].y = 40;
  4817.                star[1].x = 203;
  4818.                star[1].y = 401;
  4819.                star[2].x = 510;
  4820.                star[2].y = 179;
  4821.                star[3].x = 130;
  4822.                star[3].y = 179;
  4823.                star[4].x = 437;
  4824.                star[4].y = 401;
  4825.  
  4826.                fillpoly(10,5,star);
  4827.  
  4828.                getch();
  4829.                restext();
  4830.                exit(0);
  4831.             }
  4832.  
  4833.  
  4834.  
  4835.  
  4836.  
  4837.  
  4838.  
  4839.  
  4840.  
  4841.  
  4842.  
  4843.  
  4844.  
  4845.  
  4846.  
  4847.  
  4848.  
  4849.  
  4850.  
  4851.  
  4852.  
  4853.  
  4854.  
  4855.  
  4856.  
  4857.  
  4858.  
  4859.  
  4860.  
  4861.  
  4862.  
  4863.  
  4864.  
  4865.                                                                          77
  4866.  
  4867.  
  4868.  
  4869.  
  4870.  
  4871.           FILLSCREEN
  4872.  
  4873.             PROTOTYPE
  4874.  
  4875.             extern void far fillscreen (int colr)
  4876.  
  4877.             INPUT
  4878.  
  4879.             colr - index to color in current palette
  4880.  
  4881.             OUTPUT
  4882.  
  4883.             no value is returned
  4884.  
  4885.             USAGE
  4886.  
  4887.             FILLSCREEN clears the entire screen with the specified color.
  4888.             All information on the screen is lost.  (Note, a faster method
  4889.             to clear the screen is to call any of the RES### functions.
  4890.             These reset the graphics screen and automatically clear it to
  4891.             color index zero as well as reset the default palette.)
  4892.  
  4893.             SEE ALSO
  4894.  
  4895.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4896.             FILLCOLOR, FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLVIEW
  4897.  
  4898.             EXAMPLE
  4899.  
  4900.             /*
  4901.              * fill the screen with a color
  4902.              */
  4903.  
  4904.             #include <stdlib.h>
  4905.             #include <conio.h>
  4906.             #include "svgacc.h"
  4907.  
  4908.             void main(void)
  4909.             {
  4910.                int vmode;
  4911.  
  4912.                vmode = videomodeget();
  4913.                if ( !whichvga() )
  4914.                  exit(1);
  4915.                if ( whichmem() < 512)
  4916.                  exit(1);
  4917.                res640();
  4918.                fillscreen(10);
  4919.                getch();
  4920.                videomodeset(vmode);
  4921.                exit(0);
  4922.             }
  4923.  
  4924.  
  4925.  
  4926.  
  4927.                                                                          78
  4928.  
  4929.  
  4930.  
  4931.  
  4932.  
  4933.           FILLVIEW
  4934.  
  4935.             PROTOTYPE
  4936.  
  4937.             extern void far fillview (int colr)
  4938.  
  4939.             INPUT
  4940.  
  4941.             colr - index to color in current palette
  4942.  
  4943.             OUTPUT
  4944.  
  4945.             no value is returned
  4946.  
  4947.             USAGE
  4948.  
  4949.             FILLVIEW fills the currently defined viewport with the
  4950.             specified color.  All information in the viewport is lost.
  4951.  
  4952.             SEE ALSO
  4953.  
  4954.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  4955.             FILLCOLOR, FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLSCREEN,
  4956.             SETVIEW
  4957.  
  4958.             EXAMPLE
  4959.  
  4960.             /*
  4961.              * fill the viewport with a color
  4962.              */
  4963.  
  4964.             #include <stdlib.h>
  4965.             #include <conio.h>
  4966.             #include "svgacc.h"
  4967.  
  4968.             void main(void)
  4969.             {
  4970.                int vmode;
  4971.  
  4972.                vmode = videomodeget();
  4973.                if ( !whichvga() )
  4974.                  exit(1);
  4975.                if ( whichmem() < 512)
  4976.                  exit(1);
  4977.                res640();
  4978.                setview(100,100,539,379);
  4979.                fillview(10);
  4980.                getch();
  4981.                videomodeset(vmode);
  4982.                exit(0);
  4983.             }
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.                                                                          79
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.           FONTGETINFO
  4996.  
  4997.             PROTOTYPE
  4998.  
  4999.             extern void far fontgetinfo (int far *wdth, int far *hght)
  5000.  
  5001.             INPUT
  5002.  
  5003.             no input parameters
  5004.  
  5005.             OUTPUT
  5006.  
  5007.             wdth - integer pointer to width in pixels of current font
  5008.             hght - integer pointer to height in pixels of current font
  5009.  
  5010.             USAGE
  5011.  
  5012.             FONTGETINFO returns in wdth and hght the dimensions of the
  5013.             currently loaded font.
  5014.  
  5015.             SEE ALSO
  5016.  
  5017.             FONTSET, FONTSYSTEM
  5018.  
  5019.             EXAMPLE
  5020.  
  5021.             /*
  5022.              * display system font width and height
  5023.              */
  5024.  
  5025.             #include <stdlib.h>
  5026.             #include <conio.h>
  5027.             #include "svgacc.h"
  5028.  
  5029.             void main(void)
  5030.             {
  5031.                int vmode;
  5032.                int fontwidth;
  5033.                int fontheight;
  5034.                char text[50];
  5035.  
  5036.                vmode = videomodeget();
  5037.                if ( !whichvga() )
  5038.                  exit(1);
  5039.                if ( whichmem() < 512)
  5040.                  exit(1);
  5041.                res640();
  5042.                fontgetinfo(&fontwidth,&fontheight);
  5043.                sprintf(text,"the system font width is: %d",fontwidth);
  5044.                drwstring(1,7,0,text,0,0);
  5045.                sprintf(text,"the system font height is: %d",fontheight);
  5046.                drwstring(1,7,0,text,0,20);
  5047.                getch();
  5048.                videomodeset(vmode);
  5049.  
  5050.  
  5051.                                                                          80
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.                exit(0);
  5058.             }
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.                                                                          81
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.           FONTSET
  5120.  
  5121.             PROTOTYPE
  5122.  
  5123.             extern void far fontset (Font far *font)
  5124.  
  5125.             INPUT
  5126.  
  5127.             font - pointer to Font structure
  5128.  
  5129.             OUTPUT
  5130.  
  5131.             no value returned
  5132.  
  5133.             USAGE
  5134.  
  5135.             FONTSET loads the current font with the data found at font.
  5136.             The Font structure is 4098 bytes long with the first two bytes
  5137.             being the width and height of the font respectively.
  5138.  
  5139.             SEE ALSO
  5140.  
  5141.             FONTGETINFO, FONTSYSTEM
  5142.  
  5143.             EXAMPLE
  5144.  
  5145.             /*
  5146.              * Load a font from disk and enable it
  5147.              */
  5148.  
  5149.             #include <stdlib.h>
  5150.             #include <conio.h>
  5151.             #include <stdio.h>
  5152.             #include "svgacc.h"
  5153.  
  5154.             Font newfont;
  5155.  
  5156.             void main(void)
  5157.             {
  5158.                int vmode;
  5159.                char text[]="The Dragon Font!";
  5160.                FILE *fontfile;
  5161.                vmode = videomodeget();
  5162.                if ( !whichvga() )
  5163.                  exit(1);
  5164.                if ( whichmem() < 512)
  5165.                  exit(1);
  5166.                if ( !res640() )
  5167.                  exit(1);
  5168.                if( (fontfile = fopen("dragon.fnt","rb")) == NULL )
  5169.                  exit (1);
  5170.                fread(&newfont,4098,1,fontfile);
  5171.                fclose(fontfile);
  5172.                fontset(&newfont);
  5173.  
  5174.  
  5175.                                                                          82
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.                drwstring(1,10,0,text,0,0);
  5182.                getch();
  5183.                videomodeset(vmode);
  5184.             }
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.                                                                          83
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.           FONTSYSTEM
  5244.  
  5245.             PROTOTYPE
  5246.  
  5247.             extern void far fontsystem (void)
  5248.  
  5249.             INPUT
  5250.  
  5251.             no input parameters
  5252.  
  5253.             OUTPUT
  5254.  
  5255.             no value returned
  5256.  
  5257.             USAGE
  5258.  
  5259.             FONTSYSTEM sets the current font to the standard system font.
  5260.             This font is automatically set when WHICHVGA is called.
  5261.  
  5262.             SEE ALSO
  5263.  
  5264.             WHICHVGA, FONTGETINFO, FONTSET
  5265.  
  5266.             EXAMPLE
  5267.  
  5268.             /* Load font from disk, enable it, and switch back to system
  5269.             font */
  5270.  
  5271.             #include <stdlib.h>
  5272.             #include <conio.h>
  5273.             #include <stdio.h>
  5274.             #include "svgacc.h"
  5275.  
  5276.             Font newfont;
  5277.  
  5278.             void main(void)
  5279.             {
  5280.                int vmode;
  5281.                char text1[]="The Dragon Font!";
  5282.                char text2[]="The System Font!";
  5283.                FILE *fontfile;
  5284.                vmode = videomodeget();
  5285.                if ( !whichvga() || (whichmem() < 512))
  5286.                  exit(1);
  5287.                if ( !res640() )
  5288.                  exit(1);
  5289.                if( (fontfile = fopen("dragon.fnt","rb")) == NULL )
  5290.                  exit(1);
  5291.                fread(&newfont,4098,1,fontfile);
  5292.                fclose(fontfile);
  5293.                fontset(&newfont);
  5294.                drwstring(1,10,0,text1,0,0);
  5295.                fontsystem();
  5296.                drwstring(1,10,0,text2,0,20);
  5297.  
  5298.  
  5299.                                                                          84
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.                getch();
  5306.                videomodeset(vmode);
  5307.             }
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.                                                                          85
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.           GETARCCOS
  5368.  
  5369.             PROTOTYPE
  5370.  
  5371.             extern long far getarccos (long cosvalue)
  5372.  
  5373.             INPUT
  5374.  
  5375.             cosvalue - number between -1 and +1 scaled up by 13 bits
  5376.             (8192)
  5377.  
  5378.             OUTPUT
  5379.  
  5380.             GETARCCOS returns the arc cosine of cosvalue in degrees.
  5381.  
  5382.             USAGE
  5383.  
  5384.             GETARCCOS returns the arc cosine in degrees for the given
  5385.             value.  The return will be between 0 and 180 degrees.
  5386.             Cosvalue should be between -8192 and +8192 representing the
  5387.             range -1 to +1.  Input values outside this range are invalid
  5388.             and GETARCCOS will return -32768.  This function uses an
  5389.             integer lookup table stored within the library in order to
  5390.             produce the fastest possible results.  No floating point
  5391.             arithmetic is used.  The scale factor of 13 bits (8192) was
  5392.             chosen because this is the number of bits at which every
  5393.             change of one degree gives a change in the value of the sine
  5394.             (or cosine) function.
  5395.  
  5396.             SEE ALSO
  5397.  
  5398.             GETARCSIN, GETARCTAN, GETCOS, GETSIN, GETTAN
  5399.  
  5400.             EXAMPLE
  5401.  
  5402.             /*
  5403.              * show getarccos
  5404.              */
  5405.  
  5406.             #include <stdlib.h>
  5407.             #include <conio.h>
  5408.             #include "svgacc.h"
  5409.  
  5410.             void main(void)
  5411.             {
  5412.                int ang;
  5413.                long valueX8192;
  5414.                float value;
  5415.  
  5416.                for(value=0;value<1;value+=.05)
  5417.                {
  5418.                  valueX8192 = 8192 * value;
  5419.                  ang = getarccos(valueX8192);
  5420.                  printf("arccos of %f = %d degrees\n",value,ang);
  5421.  
  5422.  
  5423.                                                                          86
  5424.  
  5425.  
  5426.  
  5427.  
  5428.  
  5429.                }
  5430.                exit(0);
  5431.             }
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443.  
  5444.  
  5445.  
  5446.  
  5447.  
  5448.  
  5449.  
  5450.  
  5451.  
  5452.  
  5453.  
  5454.  
  5455.  
  5456.  
  5457.  
  5458.  
  5459.  
  5460.  
  5461.  
  5462.  
  5463.  
  5464.  
  5465.  
  5466.  
  5467.  
  5468.  
  5469.  
  5470.  
  5471.  
  5472.  
  5473.  
  5474.  
  5475.  
  5476.  
  5477.  
  5478.  
  5479.  
  5480.  
  5481.  
  5482.  
  5483.  
  5484.  
  5485.                                                                          87
  5486.  
  5487.  
  5488.  
  5489.  
  5490.  
  5491.           GETARCSIN
  5492.  
  5493.             PROTOTYPE
  5494.  
  5495.             extern long far getarcsin (long sinvalue)
  5496.  
  5497.             INPUT
  5498.  
  5499.             sinvalue - number between -1 and +1 scaled up by 13 bits
  5500.             (8192)
  5501.  
  5502.             OUTPUT
  5503.  
  5504.             GETARCSIN returns the arc sine of sinvalue in degrees.
  5505.  
  5506.             USAGE
  5507.  
  5508.             GETARCSIN returns the arc sine in degrees for the given value.
  5509.             The return will be between -90 and +90 degrees.  Sinvalue
  5510.             should be between -8192 and +8192 representing the range -1 to
  5511.             +1.  Input values outside this range are invalid and GETARCSIN
  5512.             will return -32768.  This function uses an integer lookup
  5513.             table stored within the library in order to produce the
  5514.             fastest possible results.  No floating point arithmetic is
  5515.             used.  The scale factor of 13 bits (8192) was chosen because
  5516.             this is the number of bits at which every change of one degree
  5517.             gives a change in the value of the sine (or cosine) function.
  5518.  
  5519.             SEE ALSO
  5520.  
  5521.             GETARCCOS, GETARCTAN, GETCOS, GETSIN, GETTAN
  5522.  
  5523.             EXAMPLE
  5524.  
  5525.             /*
  5526.              * show getarcsin
  5527.              */
  5528.  
  5529.             #include <stdlib.h>
  5530.             #include <conio.h>
  5531.             #include "svgacc.h"
  5532.  
  5533.             void main(void)
  5534.             {
  5535.                int ang;
  5536.                long valueX8192;
  5537.                float value;
  5538.  
  5539.                for(value=0;value<1;value+=.05)
  5540.                {
  5541.                  valueX8192 = 8192 * value;
  5542.                  ang = getarcsin(valueX8192);
  5543.                  printf("arcsin of %f = %d degrees\n",value,ang);
  5544.                }
  5545.  
  5546.  
  5547.                                                                          88
  5548.  
  5549.  
  5550.  
  5551.  
  5552.  
  5553.                exit(0);
  5554.             }
  5555.  
  5556.  
  5557.  
  5558.  
  5559.  
  5560.  
  5561.  
  5562.  
  5563.  
  5564.  
  5565.  
  5566.  
  5567.  
  5568.  
  5569.  
  5570.  
  5571.  
  5572.  
  5573.  
  5574.  
  5575.  
  5576.  
  5577.  
  5578.  
  5579.  
  5580.  
  5581.  
  5582.  
  5583.  
  5584.  
  5585.  
  5586.  
  5587.  
  5588.  
  5589.  
  5590.  
  5591.  
  5592.  
  5593.  
  5594.  
  5595.  
  5596.  
  5597.  
  5598.  
  5599.  
  5600.  
  5601.  
  5602.  
  5603.  
  5604.  
  5605.  
  5606.  
  5607.  
  5608.  
  5609.                                                                          89
  5610.  
  5611.  
  5612.  
  5613.  
  5614.  
  5615.           GETARCTAN
  5616.  
  5617.             PROTOTYPE
  5618.  
  5619.             extern long far getarctan (long tanvalue)
  5620.  
  5621.             INPUT
  5622.  
  5623.             tanvalue - long integer representing a decimal scaled up by 13
  5624.             bits (8192)
  5625.  
  5626.             OUTPUT
  5627.  
  5628.             GETARCTAN returns the arc tangent of tanvalue in degrees.
  5629.  
  5630.             USAGE
  5631.  
  5632.             GETARCTAN returns the arc tangent in degrees for the given
  5633.             value.  The return will be between -89 and +89 degrees.
  5634.             Tanvalue can be any long integer.  It is interpreted as a
  5635.             decimal scaled up by 8192 (13 bits).  This function uses an
  5636.             integer lookup table stored within the library in order to
  5637.             produce the fastest possible results.  No floating point
  5638.             arithmetic is used.  The scale factor of 13 bits (8192) was
  5639.             chosen because this is the number of bits at which every
  5640.             change of one degree gives a change in the value of the sine
  5641.             (or cosine) function.
  5642.  
  5643.             SEE ALSO
  5644.  
  5645.             GETARCCOS, GETARCSIN, GETCOS, GETSIN, GETTAN
  5646.  
  5647.             EXAMPLE
  5648.  
  5649.             /*
  5650.              * show getarctan
  5651.              */
  5652.  
  5653.             #include <stdlib.h>
  5654.             #include <conio.h>
  5655.             #include "svgacc.h"
  5656.  
  5657.             void main(void)
  5658.             {
  5659.                int tanang;
  5660.                int ang;
  5661.                long valueX8192;
  5662.                float value;
  5663.  
  5664.                for(value=0;value<2;value+=.1)
  5665.                {
  5666.                  valueX8192 = 8192 * value;
  5667.                  ang = getarctan(valueX8192);
  5668.                  printf("arctan of %f = %d degrees\n",value,ang);
  5669.  
  5670.  
  5671.                                                                          90
  5672.  
  5673.  
  5674.  
  5675.  
  5676.  
  5677.                }
  5678.                exit(0);
  5679.             }
  5680.  
  5681.  
  5682.  
  5683.  
  5684.  
  5685.  
  5686.  
  5687.  
  5688.  
  5689.  
  5690.  
  5691.  
  5692.  
  5693.  
  5694.  
  5695.  
  5696.  
  5697.  
  5698.  
  5699.  
  5700.  
  5701.  
  5702.  
  5703.  
  5704.  
  5705.  
  5706.  
  5707.  
  5708.  
  5709.  
  5710.  
  5711.  
  5712.  
  5713.  
  5714.  
  5715.  
  5716.  
  5717.  
  5718.  
  5719.  
  5720.  
  5721.  
  5722.  
  5723.  
  5724.  
  5725.  
  5726.  
  5727.  
  5728.  
  5729.  
  5730.  
  5731.  
  5732.  
  5733.                                                                          91
  5734.  
  5735.  
  5736.  
  5737.  
  5738.  
  5739.           GETCOS
  5740.  
  5741.             PROTOTYPE
  5742.  
  5743.             extern long far getcos (long angle)
  5744.  
  5745.             INPUT
  5746.  
  5747.             angle - angle in degrees
  5748.  
  5749.             OUTPUT
  5750.  
  5751.             GETCOS returns the cosine of angle scaled up by 13 bits
  5752.             (8192).
  5753.  
  5754.             USAGE
  5755.  
  5756.             GETCOS returns the cosine of the specified angle.  Angle can
  5757.             be any long value.  The return value has been multiplied by
  5758.             8192.  This function uses an integer lookup table stored
  5759.             within the library in order to produce the fastest possible
  5760.             results.  No floating point arithmetic is used.  The scale
  5761.             factor of 13 bits (8192) was chosen because this is the number
  5762.             of bits at which every change of one degree gives a change in
  5763.             the value of the sine (or cosine) function.
  5764.  
  5765.             SEE ALSO
  5766.  
  5767.             GETARCCOS, GETARCSIN, GETARCTAN, GETSIN, GETTAN
  5768.  
  5769.             EXAMPLE
  5770.  
  5771.             /*
  5772.              * show getcos
  5773.              */
  5774.  
  5775.             #include <stdlib.h>
  5776.             #include <conio.h>
  5777.             #include "svgacc.h"
  5778.  
  5779.             void main(void)
  5780.             {
  5781.                int ang;
  5782.                float value;
  5783.  
  5784.                for(ang=0;ang<90;ang+=5)
  5785.                {
  5786.                  value = (float)getcos(ang) / 8192;
  5787.                  printf("cos of %d degrees = %f\n",ang,value);
  5788.                }
  5789.                exit(0);
  5790.             }
  5791.  
  5792.  
  5793.  
  5794.  
  5795.                                                                          92
  5796.  
  5797.  
  5798.  
  5799.  
  5800.  
  5801.           GETLASTSTRING
  5802.  
  5803.             PROTOTYPE
  5804.  
  5805.             extern void far getlaststring (RasterBlock far *strnggfxblk)
  5806.  
  5807.             INPUT
  5808.  
  5809.             no input parameters
  5810.  
  5811.             OUTPUT
  5812.  
  5813.             no value returned
  5814.             strnggfxblk - RasterBlock pointer to destination array
  5815.  
  5816.             USAGE
  5817.  
  5818.             GETLASTSTRING returns the text drawn on the screen by the last
  5819.             called DRWSTRING function.  The text is returned in
  5820.             strnggfxblk which may be used with BLKPUT or the sprite
  5821.             functions.  The text in strnggfxblk is oriented in the same
  5822.             manner as the last called DRWSTRING function.  The suggested
  5823.             practice is to call the DRWSTRING function using mode
  5824.             NO_ACTION which does not actually draw text on the screen.
  5825.             GETLASTSTRING should be called immediately after the desired
  5826.             DRWSTRING function to prevent possible loss of data caused by
  5827.             other functions.
  5828.  
  5829.             The number of bytes of raster data needed by strnggfxblk is
  5830.             equal to
  5831.  
  5832.                          (fontwidth*stringlength)*(fontheight)
  5833.  
  5834.             plus four bytes for the width and height integers in the
  5835.             RasterBlock structure.
  5836.  
  5837.             The font's dimensions can be obtained by calling FONTGETINFO
  5838.             and the string's length can be obtained using the STRLEN
  5839.             function.  Note, however, that strnggfxblk can be quite large.
  5840.             If insufficient space is allocated for strnggfxblk,
  5841.             GETLASTSTRING will overwrite any data in memory contained
  5842.             beyond strnggfxblk and may possibly cause the system to crash.
  5843.  
  5844.             SEE ALSO
  5845.  
  5846.             BLKPUT, DRWSTRING, DRWSTRINGDN, DRWSTRINGLT, DRWSTRINGRT,
  5847.             FONTGETINFO
  5848.  
  5849.             EXAMPLE
  5850.  
  5851.             /*
  5852.              * Draws some text using the 'NO-ACTION' mode then
  5853.              * retrieve the raster data as a 'RasterBlock'
  5854.              */
  5855.  
  5856.  
  5857.                                                                          93
  5858.  
  5859.  
  5860.  
  5861.  
  5862.  
  5863.  
  5864.             #include <stdlib.h>
  5865.             #include <conio.h>
  5866.             #include "svgacc.h"
  5867.  
  5868.             void main(void)
  5869.             {
  5870.                int vmode,fontwidth,fontheight;
  5871.                char text[]="hello world";
  5872.                RasterBlock *blkdata;
  5873.                vmode = videomodeget();
  5874.                if ( !whichvga() || (whichmem() < 512))
  5875.                  exit(1);
  5876.                if ( !res640() )
  5877.                  exit(1);
  5878.                drwstringrt(NO_ACTION,10,0,text,320,240);
  5879.                fontgetinfo(&fontwidth,&fontheight);
  5880.                blkdata = (RasterBlock *)malloc(fontwidth*11*fontheight +
  5881.             4);
  5882.                getlaststring(blkdata);
  5883.                blkput(SET,0,0,blkdata);
  5884.                getch();
  5885.                videomodeset(vmode);
  5886.             }
  5887.  
  5888.  
  5889.  
  5890.  
  5891.  
  5892.  
  5893.  
  5894.  
  5895.  
  5896.  
  5897.  
  5898.  
  5899.  
  5900.  
  5901.  
  5902.  
  5903.  
  5904.  
  5905.  
  5906.  
  5907.  
  5908.  
  5909.  
  5910.  
  5911.  
  5912.  
  5913.  
  5914.  
  5915.  
  5916.  
  5917.  
  5918.  
  5919.                                                                          94
  5920.  
  5921.  
  5922.  
  5923.  
  5924.  
  5925.           GETPOINT
  5926.  
  5927.             PROTOTYPE
  5928.  
  5929.             extern int far getpoint (int x, int y)
  5930.  
  5931.             INPUT
  5932.  
  5933.             x, y - location of pixel to read
  5934.  
  5935.             OUTPUT
  5936.  
  5937.             GETPOINT returns the color index of the pixel at x, y.
  5938.  
  5939.             USAGE
  5940.  
  5941.             GETPOINT returns the value of the pixel at location x, y.
  5942.             This value is a color index into the current palette.
  5943.  
  5944.             SEE ALSO
  5945.  
  5946.             DRWPOINT
  5947.  
  5948.             EXAMPLE
  5949.  
  5950.             /*
  5951.              * draw a point and check that it is there
  5952.              */
  5953.  
  5954.             #include <stdlib.h>
  5955.             #include <conio.h>
  5956.             #include "svgacc.h"
  5957.  
  5958.             void main(void)
  5959.             {
  5960.                int vmode;
  5961.                int pointvalue;
  5962.                char text[50];
  5963.  
  5964.                vmode = videomodeget();
  5965.                if ( !whichvga() )
  5966.                  exit(1);
  5967.                if ( whichmem() < 512)
  5968.                  exit(1);
  5969.                res640();
  5970.                drwpoint(1,10,320,240);
  5971.                pointvalue = getpoint(320,240);
  5972.                sprintf(text,"the point value is: %d",pointvalue);
  5973.                drwstring(1,7,0,text,0,0);
  5974.                getch();
  5975.                videomodeset(vmode);
  5976.                exit(0);
  5977.             }
  5978.  
  5979.  
  5980.  
  5981.                                                                          95
  5982.  
  5983.  
  5984.  
  5985.  
  5986.  
  5987.           GETSIN
  5988.  
  5989.             PROTOTYPE
  5990.  
  5991.             extern long far getsin (long angle)
  5992.  
  5993.             INPUT
  5994.  
  5995.             angle - angle in degrees
  5996.  
  5997.             OUTPUT
  5998.  
  5999.             GETSIN returns the sine of angle scaled up by 13 bits (8192).
  6000.  
  6001.             USAGE
  6002.  
  6003.             GETSIN returns the sine of the specified angle.  Angle can be
  6004.             any long value.  The return value has been multiplied by 8192.
  6005.             This function uses an integer lookup table stored within the
  6006.             library in order to produce the fastest possible results.  No
  6007.             floating point arithmetic is used.  The scale factor of 13
  6008.             bits (8192) was chosen because this is the number of bits at
  6009.             which every change of one degree gives a change in the value
  6010.             of the sine (or cosine) function.
  6011.  
  6012.             SEE ALSO
  6013.  
  6014.             GETARCCOS, GETARCSIN, GETARCTAN, GETCOS, GETTAN
  6015.  
  6016.             EXAMPLE
  6017.  
  6018.             /*
  6019.              * show getsin
  6020.              */
  6021.  
  6022.             #include <stdlib.h>
  6023.             #include <conio.h>
  6024.             #include "svgacc.h"
  6025.  
  6026.             void main(void)
  6027.             {
  6028.                int sinang, ang;
  6029.                float value;
  6030.  
  6031.                for(ang=0;ang<90;ang+=5)
  6032.                {
  6033.                  value = (float)getsin(ang) / 8192;
  6034.                  printf("sin of %d degrees = %f\n",ang,value);
  6035.                }
  6036.                exit(0);
  6037.             }
  6038.  
  6039.  
  6040.  
  6041.  
  6042.  
  6043.                                                                          96
  6044.  
  6045.  
  6046.  
  6047.  
  6048.  
  6049.           GETTAN
  6050.  
  6051.             PROTOTYPE
  6052.  
  6053.             extern long far gettan (long angle)
  6054.  
  6055.             INPUT
  6056.  
  6057.             angle - angle in degrees
  6058.  
  6059.             OUTPUT
  6060.  
  6061.             GETTAN returns the tangent of angle scaled up by 13 bits
  6062.             (8192)
  6063.  
  6064.             USAGE
  6065.  
  6066.             GETTAN returns the tangent of the specified angle.  Angle can
  6067.             be any long value except +(90+n*180), where n is an integer.
  6068.             The return value has been multiplied by 8192.  If an invalid
  6069.             angle is given, the GETTAN will return &H80000000 (-
  6070.             2147483648).  This function uses an integer lookup table
  6071.             stored within the library in order to produce the fastest
  6072.             possible results.  No floating point arithmetic is used.  The
  6073.             scale factor of 13 bits (8192) was chosen because this is the
  6074.             number of bits at which every change of one degree gives a
  6075.             change in the value of the sine (or cosine) function.
  6076.  
  6077.             SEE ALSO
  6078.  
  6079.             GETARCCOS, GETARCSIN, GETARCTAN, GETCOS, GETSIN
  6080.  
  6081.             EXAMPLE
  6082.  
  6083.             /*
  6084.              * show gettan
  6085.              */
  6086.  
  6087.             #include <stdlib.h>
  6088.             #include <conio.h>
  6089.             #include "svgacc.h"
  6090.  
  6091.             void main(void)
  6092.             {
  6093.                int tanang, ang;
  6094.                float value;
  6095.  
  6096.                for(ang=0;ang<90;ang+=5)
  6097.                {
  6098.                  value = (float)gettan(ang) / 8192;
  6099.                  printf("tan of %d degrees = %f\n",ang,value);
  6100.                }
  6101.                exit(0);
  6102.             }
  6103.  
  6104.  
  6105.                                                                          97
  6106.  
  6107.  
  6108.  
  6109.  
  6110.  
  6111.            JOYSTICKINFO
  6112.  
  6113.             PROTOTYPE
  6114.  
  6115.             extern void far joystickinfo (int far *jax, int far *jay, int
  6116.             far *jabuts, int far *jbx, int far *jby, int far *jbbuts)
  6117.  
  6118.             INPUT
  6119.  
  6120.             no input parameters
  6121.  
  6122.             OUTPUT
  6123.  
  6124.             jax, jay - horizontal and vertical values of joystick A
  6125.             jabuts - button status of joystick A
  6126.             jbx, jby - horizontal and vertical values of joystick B
  6127.             jbbuts - button status of joystick B
  6128.  
  6129.             USAGE
  6130.  
  6131.             JOYSTICKINFO returns the current status of the two joysticks'
  6132.             position and buttons.  The position is returned in jax, jay
  6133.             for joystick A and jbx, jby for joystick B.  The buttons'
  6134.             status is held in jabuts and jbbuts.  For each joystick,
  6135.             button A - usually the fire button - is held in bit zero and
  6136.             button B is in bit one.  Button status is most easily checked
  6137.             with a bitwise AND of jabuts (or jbbuts) and the desired bit.
  6138.  
  6139.             Not all joysticks are constructed with the same components.
  6140.             In addition, joysticks are not linear devices.  The value of a
  6141.             joystick's center will not necessarily be the mean of its
  6142.             extreme values.  Therefore, it is recommended that any program
  6143.             using the joystick for more than just directional control
  6144.             complete a calibration of the joystick prior to usage.  For an
  6145.             example of joystick calibration, see the SVGADEMO.EXE source
  6146.             code.
  6147.  
  6148.             It is recommended, though not required, to call WHICHJOYSTICK,
  6149.             prior to using the joysticks in order to verify the existence
  6150.             of the hardware.
  6151.  
  6152.             SEE ALSO
  6153.  
  6154.             WHICHJOYSTICK
  6155.  
  6156.             EXAMPLE
  6157.  
  6158.             /*
  6159.              * show joysticks port readings
  6160.              */
  6161.  
  6162.             #include <stdlib.h>
  6163.             #include <conio.h>
  6164.             #include "svgacc.h"
  6165.  
  6166.  
  6167.                                                                          98
  6168.  
  6169.  
  6170.  
  6171.  
  6172.  
  6173.  
  6174.             void main(void)
  6175.             {
  6176.                int vmode;
  6177.                int jax, jay, jabuts, jbx, jby, jbbuts;
  6178.  
  6179.                printf("A:  X    Y  btn | B:  X    Y  btn\n  ");
  6180.                while(!kbhit()) {
  6181.                  joystickinfo(&jax,&jay,&jabuts,&jbx,&jby,&jbbuts);
  6182.                  printf("%04d %04d  %1d  |   ",jax,jay,jabuts);
  6183.                  printf("%04d %04d  %1d",jbx,jby,jbbuts);
  6184.                  printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
  6185.                  printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
  6186.                }
  6187.                getch();
  6188.             }
  6189.  
  6190.  
  6191.  
  6192.  
  6193.  
  6194.  
  6195.  
  6196.  
  6197.  
  6198.  
  6199.  
  6200.  
  6201.  
  6202.  
  6203.  
  6204.  
  6205.  
  6206.  
  6207.  
  6208.  
  6209.  
  6210.  
  6211.  
  6212.  
  6213.  
  6214.  
  6215.  
  6216.  
  6217.  
  6218.  
  6219.  
  6220.  
  6221.  
  6222.  
  6223.  
  6224.  
  6225.  
  6226.  
  6227.  
  6228.  
  6229.                                                                          99
  6230.  
  6231.  
  6232.  
  6233.  
  6234.  
  6235.           MOUSEBUTPRESS
  6236.  
  6237.             PROTOTYPE
  6238.  
  6239.             extern void far mousebutpress (int reqbut, int far *xloc, int
  6240.             far *yloc, int far *num, int far *mbuts)
  6241.  
  6242.             INPUT
  6243.  
  6244.             reqbut - button for which information is requested
  6245.  
  6246.             OUTPUT
  6247.  
  6248.             x, y - current location of mouse cursor
  6249.             num - number of times requested button has been pressed since
  6250.             last request
  6251.             mbuts - current status of mouse buttons
  6252.  
  6253.             USAGE
  6254.  
  6255.             MOUSEBUTPRESS returns in Num the number of times a mouse
  6256.             button has been pressed since the last call to MOUSEBUTPRESS.
  6257.             In addition the current status of the mouse cursor and buttons
  6258.             is returned.  The position is returned in X, Y.  The buttons'
  6259.             status is held in mbuts.  The left button is held in bit zero,
  6260.             right button in bit one and center button - for three button
  6261.             mice - in bit two.  Button status is most easily checked with
  6262.             a bitwise AND of mbuts and the desired bit.  The button for
  6263.             which a history is desired is identified by the bits in
  6264.             reqbut.  However, only one bit in reqbut may be set.
  6265.             Therefore, only the values of 1, 2 and 4 are permitted.  If
  6266.             more than one bit in reqbut is set, the function will exit and
  6267.             no information will be returned.
  6268.  
  6269.             SEE ALSO
  6270.  
  6271.             MOUSEBUTRELEASE, MOUSESTATUS
  6272.  
  6273.             EXAMPLE
  6274.  
  6275.             /* enable,show mouse / display left button press history for
  6276.             the last 2
  6277.              * seconds
  6278.              */
  6279.  
  6280.             #include <stdlib.h>
  6281.             #include <conio.h>
  6282.             #include "svgacc.h"
  6283.  
  6284.             void main(void)
  6285.             {
  6286.                int vmode, x, y, n, mbuts;
  6287.                char text[50];
  6288.  
  6289.  
  6290.  
  6291.                                                                         100
  6292.  
  6293.  
  6294.  
  6295.  
  6296.  
  6297.                char textclr[]="
  6298.             ";
  6299.  
  6300.                vmode = videomodeget();
  6301.                if ( !whichvga() )
  6302.                  exit(1);
  6303.                if ( whichmem() < 512)
  6304.                  exit(1);
  6305.                if ( !whichmouse())
  6306.                  exit(1);
  6307.                res640();
  6308.                mousecursordefault();
  6309.                mouseenter();
  6310.                mouseshow();
  6311.                while(!kbhit())
  6312.                {
  6313.                  mousebutpress(1,&x,&y,&n,&mbuts);
  6314.                  sprintf(text,"mouse x loc: %3d, y loc: %3d, number of
  6315.             times: %2d",x,y,n);
  6316.                  mousehide();
  6317.                  drwstring(1,15,8,text,0,0);
  6318.                  mouseshow();
  6319.                  sdelay(80);
  6320.                  mousehide();
  6321.                  drwstring(1,15,8,textclr,0,0);
  6322.                  mouseshow();
  6323.                }
  6324.                mousehide();
  6325.                mouseexit();
  6326.                videomodeset(vmode);
  6327.                exit(0);
  6328.             }
  6329.  
  6330.  
  6331.  
  6332.  
  6333.  
  6334.  
  6335.  
  6336.  
  6337.  
  6338.  
  6339.  
  6340.  
  6341.  
  6342.  
  6343.  
  6344.  
  6345.  
  6346.  
  6347.  
  6348.  
  6349.  
  6350.  
  6351.  
  6352.  
  6353.                                                                         101
  6354.  
  6355.  
  6356.  
  6357.  
  6358.  
  6359.           MOUSEBUTRELEASE
  6360.  
  6361.             PROTOTYPE
  6362.  
  6363.             extern void far mousebutrelease (int reqbut, int far *xloc,
  6364.             int far *yloc, int far *num, int far *mbuts)
  6365.  
  6366.             INPUT
  6367.  
  6368.             reqbut - button for which information is requested
  6369.  
  6370.             OUTPUT
  6371.  
  6372.             x, y - current location of mouse cursor
  6373.             num - number of times requested button has been released since
  6374.             last request
  6375.             mbuts - current status of mouse buttons
  6376.  
  6377.             USAGE
  6378.  
  6379.             MOUSEBUTRELEASE returns in Num the number of times a mouse
  6380.             button has been released since the last call to
  6381.             MOUSEBUTRELEASE.  In addition the current status of the mouse
  6382.             cursor and buttons is returned.  The position is returned in
  6383.             x, y.  The buttons' status is held in mbuts.  The left button
  6384.             is held in bit zero, right button in bit one and center button
  6385.             - for three button mice - in bit two.  Button status is most
  6386.             easily checked with a bitwise AND of mbuts and the desired
  6387.             bit.  The button for which a history is desired is identified
  6388.             by the bits in reqbut.  However, only one bit in reqbut may be
  6389.             set.  Therefore, only the values of 1, 2 and 4 are permitted.
  6390.             If more than one bit in reqbut is set, the function will exit
  6391.             and no information will be returned.
  6392.  
  6393.             SEE ALSO
  6394.  
  6395.             MOUSEBUTPRESS, MOUSESTATUS
  6396.  
  6397.             EXAMPLE
  6398.  
  6399.             /* enable,show mouse / display left button release history for
  6400.             the last
  6401.              * 2 seconds
  6402.              */
  6403.  
  6404.             #include <stdlib.h>
  6405.             #include <conio.h>
  6406.             #include "svgacc.h"
  6407.  
  6408.             void main(void)
  6409.             {
  6410.                int vmode, x, y, n, mbuts;
  6411.                char text[50];
  6412.  
  6413.  
  6414.  
  6415.                                                                         102
  6416.  
  6417.  
  6418.  
  6419.  
  6420.  
  6421.                char textclr[]="
  6422.             ";
  6423.  
  6424.                vmode = videomodeget();
  6425.                if ( !whichvga() )
  6426.                  exit(1);
  6427.                if ( whichmem() < 512)
  6428.                  exit(1);
  6429.                if ( !whichmouse())
  6430.                  exit(1);
  6431.                res640();
  6432.                mousecursordefault();
  6433.                mouseenter();
  6434.                mouseshow();
  6435.                while(!kbhit())
  6436.                {
  6437.                  mousebutrelease(1,&x,&y,&n,&mbuts);
  6438.                  sprintf(text,"mouse x loc: %3d, y loc: %3d, number of
  6439.             times: %2d",x,y,n);
  6440.                  mousehide();
  6441.                  drwstring(1,15,8,text,0,0);
  6442.                  mouseshow();
  6443.                  sdelay(80);
  6444.                  mousehide();
  6445.                  drwstring(1,15,8,textclr,0,0);
  6446.                  mouseshow();
  6447.                }
  6448.                mousehide();
  6449.                mouseexit();
  6450.                videomodeset(vmode);
  6451.                exit(0);
  6452.             }
  6453.  
  6454.  
  6455.  
  6456.  
  6457.  
  6458.  
  6459.  
  6460.  
  6461.  
  6462.  
  6463.  
  6464.  
  6465.  
  6466.  
  6467.  
  6468.  
  6469.  
  6470.  
  6471.  
  6472.  
  6473.  
  6474.  
  6475.  
  6476.  
  6477.                                                                         103
  6478.  
  6479.  
  6480.  
  6481.  
  6482.  
  6483.           MOUSECURSORSET
  6484.  
  6485.             PROTOTYPE
  6486.  
  6487.             extern void far mousecursorset (MouseCursor far *mousecursor)
  6488.  
  6489.             INPUT
  6490.  
  6491.             mousecursor - MouseCursor pointer to mouse cursor data
  6492.  
  6493.             OUTPUT
  6494.  
  6495.             no value returned
  6496.  
  6497.             USAGE
  6498.  
  6499.             MOUSECURSORSET defines the cursor according to the data in the
  6500.             MouseCursor structure.  The hot spot for the cursor is set by
  6501.             mousecursor.hotspotx, mousecursor.hotspoty.  The values for
  6502.             mousecursor.hotspotx and mousecursor.hotspoty must be within
  6503.             the cursor.  Valid mousecursor.hotspotx values are from 0 to
  6504.             15 and mousecursor.hotspoty ranges from 0 to 23.
  6505.  
  6506.             SEE ALSO
  6507.  
  6508.             MOUSECURSORDEFAULT, MOUSEENTER, MOUSESHOW
  6509.  
  6510.             EXAMPLE
  6511.  
  6512.             /*
  6513.              * enable,show mouse, and switch to a different mouse cursor
  6514.              */
  6515.  
  6516.             #include <stdlib.h>
  6517.             #include <conio.h>
  6518.             #include "svgacc.h"
  6519.  
  6520.             void main(void)
  6521.             {
  6522.                int vmode;
  6523.  
  6524.                MouseCursor bigmousecursor = {
  6525.                  1,1,
  6526.  
  6527.                0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,
  6528.                  0,15,15,0,0,255,255,255,255,255,255,255,255,255,255,255,
  6529.                  0,15,15,15,15,0,0,0,255,255,255,255,255,255,255,255,
  6530.                  0,15,15,15,15,15,15,15,0,0,255,255,255,255,255,255,
  6531.                  0,15,15,15,15,15,15,15,15,15,0,0,0,255,255,255,
  6532.                  0,15,15,15,15,15,15,15,15,15,15,15,15,0,0,255,
  6533.                  0,15,15,15,15,15,15,15,15,15,15,15,15,15,0,255,
  6534.                  0,15,15,15,15,15,15,15,15,15,15,15,0,0,255,255,
  6535.                  0,15,15,15,15,15,15,15,15,15,15,0,255,255,255,255,
  6536.                  0,15,15,15,15,15,15,15,15,0,0,255,255,255,255,255,
  6537.  
  6538.  
  6539.                                                                         104
  6540.  
  6541.  
  6542.  
  6543.  
  6544.  
  6545.                  0,15,15,15,15,15,15,15,15,0,255,255,255,255,255,255,
  6546.                  0,15,15,15,15,15,0,15,15,15,0,255,255,255,255,255,
  6547.                  0,15,15,15,15,0,0,15,15,15,0,255,255,255,255,255,
  6548.                  0,15,15,0,0,255,255,0,15,15,15,0,255,255,255,255,
  6549.                  0,15,0,255,255,255,255,0,15,15,15,0,255,255,255,255,
  6550.                  0,0,255,255,255,255,255,255,0,15,15,15,0,255,255,255,
  6551.                  255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,255,
  6552.                  255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,255,
  6553.                  255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,255,
  6554.                  255,255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,
  6555.                  255,255,255,255,255,255,255,255,255,255,255,0,15,15,15,0,
  6556.  
  6557.                255,255,255,255,255,255,255,255,255,255,255,255,0,15,15,0,
  6558.  
  6559.                255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,
  6560.  
  6561.                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
  6562.             255
  6563.                };
  6564.  
  6565.                vmode = videomodeget();
  6566.                if ( !whichvga() )
  6567.                  exit(1);
  6568.                if ( whichmem() < 512)
  6569.                  exit(1);
  6570.                if ( !whichmouse())
  6571.                  exit(1);
  6572.                res640();
  6573.                mouseenter();
  6574.                drwstring(1,7,0,"press a key to return to default
  6575.             cursor",0,0);
  6576.                mousecursorset(bigmousecursor);
  6577.                mouseshow();
  6578.                getch();
  6579.                mousecursordefault();
  6580.                drwstring(1,7,0,"press a key to end
  6581.             ",0,0);
  6582.                getch();
  6583.                mousehide();
  6584.                mouseexit();
  6585.                videomodeset(vmode);
  6586.                exit(0);
  6587.             }
  6588.  
  6589.  
  6590.  
  6591.  
  6592.  
  6593.  
  6594.  
  6595.  
  6596.  
  6597.  
  6598.  
  6599.  
  6600.  
  6601.                                                                         105
  6602.  
  6603.  
  6604.  
  6605.  
  6606.  
  6607.           MOUSECURSORDEFAULT
  6608.  
  6609.             PROTOTYPE
  6610.  
  6611.             extern void far mousecursordefault (void)
  6612.  
  6613.             INPUT
  6614.  
  6615.             no input parameters
  6616.  
  6617.             OUTPUT
  6618.  
  6619.             no value returned
  6620.  
  6621.             USAGE
  6622.  
  6623.             MOUSECURSORDEFAULT defines the mouse cursor to be a small
  6624.             arrow with the hot spot in the upper, left corner.  This is
  6625.             the cursor set when MOUSEENTER is called.
  6626.  
  6627.             SEE ALSO
  6628.  
  6629.             MOUSECURSORSET, MOUSEENTER
  6630.  
  6631.             EXAMPLE
  6632.  
  6633.             See MOUSECURSORSET
  6634.  
  6635.  
  6636.  
  6637.  
  6638.  
  6639.  
  6640.  
  6641.  
  6642.  
  6643.  
  6644.  
  6645.  
  6646.  
  6647.  
  6648.  
  6649.  
  6650.  
  6651.  
  6652.  
  6653.  
  6654.  
  6655.  
  6656.  
  6657.  
  6658.  
  6659.  
  6660.  
  6661.  
  6662.  
  6663.                                                                         106
  6664.  
  6665.  
  6666.  
  6667.  
  6668.  
  6669.           MOUSEENTER
  6670.  
  6671.             PROTOTYPE
  6672.  
  6673.             extern void far mouseenter (void)
  6674.  
  6675.             INPUT
  6676.  
  6677.             no input parameters
  6678.  
  6679.             OUTPUT
  6680.  
  6681.             no value returned
  6682.  
  6683.             USAGE
  6684.  
  6685.             MOUSEENTER must be called before any other mouse functions.
  6686.             It initializes all of the mouse abilities including installing
  6687.             the Zephyr mouse display driver.  MOUSEENTER initializes the
  6688.             default mouse cursor, the default sensitivity and sets the
  6689.             range to the current screen resolution.  The mouse cursor
  6690.             location is set to the middle of the screen.
  6691.  
  6692.             SEE ALSO
  6693.  
  6694.             MOUSEEXIT, MOUSEHIDE, MOUSESHOW
  6695.  
  6696.             EXAMPLE
  6697.  
  6698.             /*
  6699.              * enable,show mouse
  6700.              */
  6701.             #include <stdlib.h>
  6702.             #include <conio.h>
  6703.             #include "svgacc.h"
  6704.  
  6705.             void main(void)
  6706.             {
  6707.                int vmode;
  6708.  
  6709.                vmode = videomodeget();
  6710.                if ( !whichvga() )
  6711.                  exit(1);
  6712.                if ( whichmem() < 512)
  6713.                  exit(1);
  6714.                if ( !whichmouse())
  6715.                  exit(1);
  6716.                res640();
  6717.                mouseenter();
  6718.                mouseshow();
  6719.                getch();
  6720.                mousehide();
  6721.                mouseexit();
  6722.                videomodeset(vmode);
  6723.  
  6724.  
  6725.                                                                         107
  6726.  
  6727.  
  6728.  
  6729.  
  6730.  
  6731.                exit(0);
  6732.             }
  6733.  
  6734.  
  6735.  
  6736.  
  6737.  
  6738.  
  6739.  
  6740.  
  6741.  
  6742.  
  6743.  
  6744.  
  6745.  
  6746.  
  6747.  
  6748.  
  6749.  
  6750.  
  6751.  
  6752.  
  6753.  
  6754.  
  6755.  
  6756.  
  6757.  
  6758.  
  6759.  
  6760.  
  6761.  
  6762.  
  6763.  
  6764.  
  6765.  
  6766.  
  6767.  
  6768.  
  6769.  
  6770.  
  6771.  
  6772.  
  6773.  
  6774.  
  6775.  
  6776.  
  6777.  
  6778.  
  6779.  
  6780.  
  6781.  
  6782.  
  6783.  
  6784.  
  6785.  
  6786.  
  6787.                                                                         108
  6788.  
  6789.  
  6790.  
  6791.  
  6792.  
  6793.           MOUSEEXIT
  6794.  
  6795.             PROTOTYPE
  6796.  
  6797.             extern void far mouseexit (void)
  6798.  
  6799.             INPUT
  6800.  
  6801.             no input parameters
  6802.  
  6803.             OUTPUT
  6804.  
  6805.             no value returned
  6806.  
  6807.             USAGE
  6808.  
  6809.             MOUSEEXIT properly disables all of the mouse abilities.  This
  6810.             function also removes the Zephyr mouse display driver.  This
  6811.             function should be called prior to exiting any program that
  6812.             previously called MOUSEENTER.
  6813.  
  6814.             SEE ALSO
  6815.  
  6816.             MOUSEENTER, MOUSEHIDE, MOUSESHOW
  6817.  
  6818.             EXAMPLE
  6819.  
  6820.             /*
  6821.              * enable,show mouse, then disable it
  6822.              */
  6823.             #include <stdlib.h>
  6824.             #include <conio.h>
  6825.             #include "svgacc.h"
  6826.  
  6827.             void main(void)
  6828.             {
  6829.                int vmode;
  6830.  
  6831.                vmode = videomodeget();
  6832.                if ( !whichvga() )
  6833.                  exit(1);
  6834.                if ( whichmem() < 512)
  6835.                  exit(1);
  6836.                if ( !whichmouse())
  6837.                  exit(1);
  6838.                res640();
  6839.                mousecursordefault();
  6840.                mouseenter();
  6841.                mouseshow();
  6842.                getch();
  6843.                mousehide();
  6844.                mouseexit();
  6845.                videomodeset(vmode);
  6846.                exit(0);
  6847.  
  6848.  
  6849.                                                                         109
  6850.  
  6851.  
  6852.  
  6853.  
  6854.  
  6855.             }
  6856.  
  6857.  
  6858.  
  6859.  
  6860.  
  6861.  
  6862.  
  6863.  
  6864.  
  6865.  
  6866.  
  6867.  
  6868.  
  6869.  
  6870.  
  6871.  
  6872.  
  6873.  
  6874.  
  6875.  
  6876.  
  6877.  
  6878.  
  6879.  
  6880.  
  6881.  
  6882.  
  6883.  
  6884.  
  6885.  
  6886.  
  6887.  
  6888.  
  6889.  
  6890.  
  6891.  
  6892.  
  6893.  
  6894.  
  6895.  
  6896.  
  6897.  
  6898.  
  6899.  
  6900.  
  6901.  
  6902.  
  6903.  
  6904.  
  6905.  
  6906.  
  6907.  
  6908.  
  6909.  
  6910.  
  6911.                                                                         110
  6912.  
  6913.  
  6914.  
  6915.  
  6916.  
  6917.           MOUSEHIDE
  6918.  
  6919.             PROTOTYPE
  6920.  
  6921.             extern void far mousehide (void)
  6922.  
  6923.             INPUT
  6924.  
  6925.             no input parameters
  6926.  
  6927.             OUTPUT
  6928.  
  6929.             no value returned
  6930.  
  6931.             USAGE
  6932.  
  6933.             MOUSEHIDE turns off the mouse display driver and removes the
  6934.             cursor from the display.  It is recommended to hide the mouse
  6935.             any time something will be drawn in its general vicinity.
  6936.             Note, however, that although the cursor is not visible, all
  6937.             other mouse abilities remain active.
  6938.  
  6939.             SEE ALSO
  6940.  
  6941.             MOUSEENTER, MOUSEEXIT, MOUSESHOW
  6942.  
  6943.             EXAMPLE
  6944.  
  6945.             /*
  6946.              * enable,show mouse,hide mouse
  6947.              */
  6948.             #include <stdlib.h>
  6949.             #include <conio.h>
  6950.             #include "svgacc.h"
  6951.             void main(void)
  6952.             {
  6953.                int vmode;
  6954.  
  6955.                vmode = videomodeget();
  6956.                if ( !whichvga() )
  6957.                  exit(1);
  6958.                if ( whichmem() < 512)
  6959.                  exit(1);
  6960.                if ( !whichmouse())
  6961.                  exit(1);
  6962.                res640();
  6963.                mousecursordefault();
  6964.                mouseenter();
  6965.                mouseshow();
  6966.                getch();
  6967.                mousehide();
  6968.                getch();
  6969.                mouseexit();
  6970.                videomodeset(vmode);
  6971.  
  6972.  
  6973.                                                                         111
  6974.  
  6975.  
  6976.  
  6977.  
  6978.  
  6979.                exit(0);
  6980.             }
  6981.  
  6982.  
  6983.  
  6984.  
  6985.  
  6986.  
  6987.  
  6988.  
  6989.  
  6990.  
  6991.  
  6992.  
  6993.  
  6994.  
  6995.  
  6996.  
  6997.  
  6998.  
  6999.  
  7000.  
  7001.  
  7002.  
  7003.  
  7004.  
  7005.  
  7006.  
  7007.  
  7008.  
  7009.  
  7010.  
  7011.  
  7012.  
  7013.  
  7014.  
  7015.  
  7016.  
  7017.  
  7018.  
  7019.  
  7020.  
  7021.  
  7022.  
  7023.  
  7024.  
  7025.  
  7026.  
  7027.  
  7028.  
  7029.  
  7030.  
  7031.  
  7032.  
  7033.  
  7034.  
  7035.                                                                         112
  7036.  
  7037.  
  7038.  
  7039.  
  7040.  
  7041.           MOUSEINFO
  7042.  
  7043.             PROTOTYPE
  7044.  
  7045.             extern void far mouseinfo (int far *drvmajorver, int far
  7046.             *drvminorver, int far *mousetype, int far *irqnumber)
  7047.  
  7048.             INPUT
  7049.  
  7050.             no input parameters
  7051.  
  7052.             OUTPUT
  7053.  
  7054.             drvmajorver - Microsoft compatible mouse driver major version
  7055.             number
  7056.             drvminorver - Microsoft compatible mouse driver minor version
  7057.             number
  7058.             mousetype - type of mouse installed
  7059.             irqnumber - interrupt used by the mouse
  7060.  
  7061.             USAGE
  7062.  
  7063.             MOUSEINFO returns information about the mouse and its
  7064.             installed driver.  The driver must be Microsoft compatible.
  7065.             This information can be used to determine whether the mouse
  7066.             functions in this library will operate correctly.  For proper
  7067.             operation the driver version number must be greater than 1.00.
  7068.             Irqnumber gives the interrupt number of the mouse.  Mousetype
  7069.             returns information about the type of hardware installed
  7070.             according to the following table:
  7071.  
  7072.             0 =  unknown type
  7073.             1 =  bus mouse
  7074.             2 =  serial mouse
  7075.             3 =  Inport mouse
  7076.             4 =  PS/2 mouse
  7077.             5 =  HP mouse
  7078.  
  7079.             SEE ALSO
  7080.  
  7081.             WHICHMOUSE
  7082.  
  7083.             EXAMPLE
  7084.  
  7085.             /*
  7086.              * id any installed mouse
  7087.              */
  7088.  
  7089.             #include <stdlib.h>
  7090.             #include <conio.h>
  7091.             #include "svgacc.h"
  7092.  
  7093.             void main(void)
  7094.             {
  7095.  
  7096.  
  7097.                                                                         113
  7098.  
  7099.  
  7100.  
  7101.  
  7102.  
  7103.                int mjv, mnv, tp, i, mouse;
  7104.                char buf[100];
  7105.  
  7106.                mouse = whichmouse();
  7107.                if (mouse > 0) {
  7108.                  mouseinfo(&mjv, &mnv, &tp, &i);
  7109.                  switch (tp) {
  7110.                     case 1:
  7111.                       sprintf(buf,"bus mouse");
  7112.                       break;
  7113.                     case 2:
  7114.                       sprintf(buf,"serial mouse");
  7115.                       break;
  7116.                     case 3:
  7117.                       sprintf(buf,"Inport mouse");
  7118.                       break;
  7119.                     case 4:
  7120.                       sprintf(buf,"PS/2 mouse");
  7121.                       break;
  7122.                     case 5:
  7123.                       sprintf(buf,"HP mouse");
  7124.                       break;
  7125.                     default:
  7126.                       sprintf(buf,"unknown type");
  7127.                  }
  7128.                  printf("Microsoft compatible %s detected with %d buttons
  7129.             on IRQ %d.\n", &buf, mouse, i);
  7130.                  printf("Software driver version is %d.%d (Microsoft
  7131.             equivalent version).\n\n", mjv, mnv);
  7132.  
  7133.                } else
  7134.                  printf("No Microsoft compatible mouse detected.\n\n");
  7135.             }
  7136.  
  7137.  
  7138.  
  7139.  
  7140.  
  7141.  
  7142.  
  7143.  
  7144.  
  7145.  
  7146.  
  7147.  
  7148.  
  7149.  
  7150.  
  7151.  
  7152.  
  7153.  
  7154.  
  7155.  
  7156.  
  7157.  
  7158.  
  7159.                                                                         114
  7160.  
  7161.  
  7162.  
  7163.  
  7164.  
  7165.           MOUSELOCSET
  7166.  
  7167.             PROTOTYPE
  7168.  
  7169.             extern void far mouselocset (int xloc, int yloc)
  7170.  
  7171.             INPUT
  7172.  
  7173.             x, y - location on screen
  7174.  
  7175.             OUTPUT
  7176.  
  7177.             no value returned
  7178.  
  7179.             USAGE
  7180.  
  7181.             MOUSELOCSET moves the mouse cursor the location on the screen
  7182.             specified by x, y.  If either x or y is outside of the
  7183.             currently permitted mouse range, it is set to the closest
  7184.             border.  The currently permitted mouse range is the current
  7185.             screen resolution or the last called MOUSERANGESET.
  7186.  
  7187.             SEE ALSO
  7188.  
  7189.             MOUSEENTER, MOUSERANGESET
  7190.  
  7191.             EXAMPLE
  7192.  
  7193.             /*
  7194.              * enable,show mouse then move it to the origin
  7195.              */
  7196.             #include <stdlib.h>
  7197.             #include <conio.h>
  7198.             #include "svgacc.h"
  7199.             void main(void)
  7200.             {
  7201.                int vmode;
  7202.                vmode = videomodeget();
  7203.                if ( !whichvga() )
  7204.                  exit(1);
  7205.                if ( whichmem() < 512)
  7206.                  exit(1);
  7207.                if ( !whichmouse())
  7208.                  exit(1);
  7209.                res640();
  7210.                mousecursordefault();
  7211.                mouseenter();
  7212.                mouseshow();
  7213.                getch();
  7214.                mouselocset(0,0);
  7215.                getch();
  7216.                mousehide();
  7217.                mouseexit();
  7218.                videomodeset(vmode);
  7219.  
  7220.  
  7221.                                                                         115
  7222.  
  7223.  
  7224.  
  7225.  
  7226.  
  7227.                exit(0);
  7228.             }
  7229.  
  7230.  
  7231.  
  7232.  
  7233.  
  7234.  
  7235.  
  7236.  
  7237.  
  7238.  
  7239.  
  7240.  
  7241.  
  7242.  
  7243.  
  7244.  
  7245.  
  7246.  
  7247.  
  7248.  
  7249.  
  7250.  
  7251.  
  7252.  
  7253.  
  7254.  
  7255.  
  7256.  
  7257.  
  7258.  
  7259.  
  7260.  
  7261.  
  7262.  
  7263.  
  7264.  
  7265.  
  7266.  
  7267.  
  7268.  
  7269.  
  7270.  
  7271.  
  7272.  
  7273.  
  7274.  
  7275.  
  7276.  
  7277.  
  7278.  
  7279.  
  7280.  
  7281.  
  7282.  
  7283.                                                                         116
  7284.  
  7285.  
  7286.  
  7287.  
  7288.  
  7289.           MOUSERANGESET
  7290.  
  7291.             PROTOTYPE
  7292.  
  7293.             extern void far mouserangeset (int x1, int y1, int x2, int y2)
  7294.  
  7295.             INPUT
  7296.  
  7297.             x1, y1 - location on screen of top, left corner of range
  7298.             x2, y2 - location on screen of bottom, right corner of range
  7299.  
  7300.             OUTPUT
  7301.  
  7302.             no value returned
  7303.  
  7304.             USAGE
  7305.  
  7306.             MOUSERANGESET defines a permissible range on the screen for
  7307.             mouse movement.  The mouse is automatically positioned in the
  7308.             center of this range.
  7309.  
  7310.             SEE ALSO
  7311.  
  7312.             MOUSELOCSET, MOUSESTATUS
  7313.  
  7314.             EXAMPLE
  7315.  
  7316.             /*
  7317.              * enable,show and set a range for the mouse
  7318.              */
  7319.  
  7320.             #include <stdlib.h>
  7321.             #include <conio.h>
  7322.             #include "svgacc.h"
  7323.  
  7324.             void main(void)
  7325.             {
  7326.                int vmode;
  7327.                vmode = videomodeget();
  7328.                if ( !whichvga() )
  7329.                  exit(1);
  7330.                if ( whichmem() < 512)
  7331.                  exit(1);
  7332.                if ( !whichmouse())
  7333.                  exit(1);
  7334.                if ( !res640() )
  7335.                  exit(1);
  7336.                mouseenter();
  7337.                drwbox(1,10,100,100,539,379);
  7338.                mouserangeset(100,100,539,379);
  7339.                mouseshow();
  7340.                getch();
  7341.                mousehide();
  7342.                mouseexit();
  7343.  
  7344.  
  7345.                                                                         117
  7346.  
  7347.  
  7348.  
  7349.  
  7350.  
  7351.                videomodeset(vmode);
  7352.                exit(0);
  7353.             }
  7354.  
  7355.  
  7356.  
  7357.  
  7358.  
  7359.  
  7360.  
  7361.  
  7362.  
  7363.  
  7364.  
  7365.  
  7366.  
  7367.  
  7368.  
  7369.  
  7370.  
  7371.  
  7372.  
  7373.  
  7374.  
  7375.  
  7376.  
  7377.  
  7378.  
  7379.  
  7380.  
  7381.  
  7382.  
  7383.  
  7384.  
  7385.  
  7386.  
  7387.  
  7388.  
  7389.  
  7390.  
  7391.  
  7392.  
  7393.  
  7394.  
  7395.  
  7396.  
  7397.  
  7398.  
  7399.  
  7400.  
  7401.  
  7402.  
  7403.  
  7404.  
  7405.  
  7406.  
  7407.                                                                         118
  7408.  
  7409.  
  7410.  
  7411.  
  7412.  
  7413.           MOUSERESTORESTATE
  7414.  
  7415.             PROTOTYPE
  7416.  
  7417.             extern void far mouserestorestate (byte far *mousebuf)
  7418.  
  7419.             INPUT
  7420.  
  7421.             mousebuf - byte pointer to buffer holding complete mouse
  7422.             status information
  7423.  
  7424.             OUTPUT
  7425.  
  7426.             no value returned
  7427.  
  7428.             USAGE
  7429.  
  7430.             MOUSERESTORESTATE completely restores a previously saved mouse
  7431.             status as contained in mousebuf.  The mouse status must have
  7432.             been already stored in mousebuf by MOUSESAVESTATE.
  7433.  
  7434.             SEE ALSO
  7435.  
  7436.             MOUSESAVESTATE, MOUSESTORAGESIZE
  7437.  
  7438.             EXAMPLE
  7439.  
  7440.             /*
  7441.              * save the mouse driver state,shell out to DOS, restore the
  7442.             driver state
  7443.              */
  7444.  
  7445.             #include <stdlib.h>
  7446.             #include <conio.h>
  7447.             #include <process.h>
  7448.             #include "svgacc.h"
  7449.  
  7450.             void main(void)
  7451.             {
  7452.                int rt, bufsiz;
  7453.                byte *mousedriverdata;
  7454.                char cmdcom[]="C:\COMMAND.COM";
  7455.                char *args[1];
  7456.  
  7457.                if ( !whichmouse())
  7458.                  exit(1);
  7459.                bufsiz=mousestoragesize();
  7460.                mousedriverdata = (byte *)malloc(bufsiz);
  7461.                mousesavestate(mousedriverdata);
  7462.                printf("* Type Exit To Return To Program *");
  7463.                args[0]=NULL;
  7464.                rt=spawnv(P_WAIT,cmdcom,args);
  7465.                mouserestorestate(mousedriverdata);
  7466.                printf("mouse driver data restored...");
  7467.  
  7468.  
  7469.                                                                         119
  7470.  
  7471.  
  7472.  
  7473.  
  7474.  
  7475.                exit(0);
  7476.             }
  7477.  
  7478.  
  7479.  
  7480.  
  7481.  
  7482.  
  7483.  
  7484.  
  7485.  
  7486.  
  7487.  
  7488.  
  7489.  
  7490.  
  7491.  
  7492.  
  7493.  
  7494.  
  7495.  
  7496.  
  7497.  
  7498.  
  7499.  
  7500.  
  7501.  
  7502.  
  7503.  
  7504.  
  7505.  
  7506.  
  7507.  
  7508.  
  7509.  
  7510.  
  7511.  
  7512.  
  7513.  
  7514.  
  7515.  
  7516.  
  7517.  
  7518.  
  7519.  
  7520.  
  7521.  
  7522.  
  7523.  
  7524.  
  7525.  
  7526.  
  7527.  
  7528.  
  7529.  
  7530.  
  7531.                                                                         120
  7532.  
  7533.  
  7534.  
  7535.  
  7536.  
  7537.           MOUSESAVESTATE
  7538.  
  7539.             PROTOTYPE
  7540.  
  7541.             extern void far mousesavestate (byte far *mousebuf)
  7542.  
  7543.             INPUT
  7544.  
  7545.             no input parameters
  7546.  
  7547.             OUTPUT
  7548.  
  7549.             no value returned
  7550.             mousebuf - buffer holding complete mouse status information
  7551.  
  7552.             USAGE
  7553.  
  7554.             MOUSESAVESTATE saves the complete mouse status in mousebuf.
  7555.             The size of mousebuf in bytes is defined by MOUSESTORAGESIZE
  7556.             which should called first.
  7557.  
  7558.             SEE ALSO
  7559.  
  7560.             MOUSERESTORESTATE, MOUSESTORAGESIZE
  7561.  
  7562.             EXAMPLE
  7563.  
  7564.             See MOUSERESTORESTATE
  7565.  
  7566.  
  7567.  
  7568.  
  7569.  
  7570.  
  7571.  
  7572.  
  7573.  
  7574.  
  7575.  
  7576.  
  7577.  
  7578.  
  7579.  
  7580.  
  7581.  
  7582.  
  7583.  
  7584.  
  7585.  
  7586.  
  7587.  
  7588.  
  7589.  
  7590.  
  7591.  
  7592.  
  7593.                                                                         121
  7594.  
  7595.  
  7596.  
  7597.  
  7598.  
  7599.           MOUSESENSSET
  7600.  
  7601.             PROTOTYPE
  7602.  
  7603.             extern void far mousesensset (int xsens, int ysens, int
  7604.             dblspdthresh)
  7605.  
  7606.             INPUT
  7607.  
  7608.             xsens = number of mickeys per 8 pixels horizontally (default =
  7609.             4 mickeys per pixel)
  7610.             ysens = number of mickeys per 8 pixels vertically (default = 4
  7611.             mickeys per pixel)
  7612.             dblspdthresh=number of mickeys per second at which speed is
  7613.             doubled (default = 8)
  7614.  
  7615.             OUTPUT
  7616.  
  7617.             no value returned
  7618.  
  7619.             USAGE
  7620.  
  7621.             MOUSESENSSET defines the relationship between mouse movement
  7622.             and cursor movement on the screen.  A mickey is defined as
  7623.             1/200th of an inch.  The ratio between mickeys and pixels is
  7624.             specified by xsens and ysens in the horizontal and vertical
  7625.             directions respectively.  When the mouse movement is faster
  7626.             than DblSpdThresh in mickeys per second, the speed is doubled.
  7627.             The default values are assigned whenever MOUSEENTER or
  7628.             MOUSEEXIT are called.
  7629.  
  7630.             SEE ALSO
  7631.  
  7632.             MOUSEENTER, MOUSEEXIT, MOUSESTATUS
  7633.  
  7634.             EXAMPLE
  7635.  
  7636.             /*
  7637.              * enable,show the mouse and make it very sensitive
  7638.              */
  7639.  
  7640.             #include <stdlib.h>
  7641.             #include <conio.h>
  7642.             #include "svgacc.h"
  7643.             void main(void)
  7644.             {
  7645.                int vmode;
  7646.                vmode = videomodeget();
  7647.                if ( !whichvga() )
  7648.                  exit(1);
  7649.                if ( whichmem() < 512)
  7650.                  exit(1);
  7651.                if ( !whichmouse())
  7652.                  exit(1);
  7653.  
  7654.  
  7655.                                                                         122
  7656.  
  7657.  
  7658.  
  7659.  
  7660.  
  7661.                res640();
  7662.                mousecursordefault();
  7663.                mouseenter();
  7664.                mouseshow();
  7665.                mousesensset(2, 2, 4);
  7666.                getch();
  7667.                mousehide();
  7668.                mouseexit();
  7669.                videomodeset(vmode);
  7670.                exit(0);
  7671.             }
  7672.  
  7673.  
  7674.  
  7675.  
  7676.  
  7677.  
  7678.  
  7679.  
  7680.  
  7681.  
  7682.  
  7683.  
  7684.  
  7685.  
  7686.  
  7687.  
  7688.  
  7689.  
  7690.  
  7691.  
  7692.  
  7693.  
  7694.  
  7695.  
  7696.  
  7697.  
  7698.  
  7699.  
  7700.  
  7701.  
  7702.  
  7703.  
  7704.  
  7705.  
  7706.  
  7707.  
  7708.  
  7709.  
  7710.  
  7711.  
  7712.  
  7713.  
  7714.  
  7715.  
  7716.  
  7717.                                                                         123
  7718.  
  7719.  
  7720.  
  7721.  
  7722.  
  7723.           MOUSESHOW
  7724.  
  7725.             PROTOTYPE
  7726.  
  7727.             extern void far mouseshow (void)
  7728.  
  7729.             INPUT
  7730.  
  7731.             no input parameters
  7732.  
  7733.             OUTPUT
  7734.  
  7735.             no value returned
  7736.  
  7737.             USAGE
  7738.  
  7739.             MOUSESHOW enables the mouse display driver and places the
  7740.             cursor on the screen.  The cursor is only updated when the
  7741.             mouse is moved.  Therefore, it is recommended to hide the
  7742.             cursor when drawing on the screen to avoid unexpected results.
  7743.  
  7744.             SEE ALSO
  7745.  
  7746.             MOUSEENTER, MOUSEEXIT, MOUSEHIDE
  7747.  
  7748.             EXAMPLE
  7749.  
  7750.             See MOUSEHIDE
  7751.  
  7752.  
  7753.  
  7754.  
  7755.  
  7756.  
  7757.  
  7758.  
  7759.  
  7760.  
  7761.  
  7762.  
  7763.  
  7764.  
  7765.  
  7766.  
  7767.  
  7768.  
  7769.  
  7770.  
  7771.  
  7772.  
  7773.  
  7774.  
  7775.  
  7776.  
  7777.  
  7778.  
  7779.                                                                         124
  7780.  
  7781.  
  7782.  
  7783.  
  7784.  
  7785.           MOUSESTATUS
  7786.  
  7787.             PROTOTYPE
  7788.  
  7789.             extern void far mousestatus (int far *x, int far *y, int far
  7790.             *mbuts)
  7791.  
  7792.             INPUT
  7793.  
  7794.             no input parameters
  7795.  
  7796.             OUTPUT
  7797.  
  7798.             x, y - mouse position on screen
  7799.             mbuts - status of mouse buttons
  7800.  
  7801.             USAGE
  7802.  
  7803.             MOUSESTATUS returns the current status of the mouse position
  7804.             and buttons.  The position is returned in x, y.  The buttons'
  7805.             status is held in mbuts.  The left button is held in bit zero,
  7806.             right button in bit one and center button - for three button
  7807.             mice - in bit two.  Button status is most easily checked with
  7808.             a bitwise AND of mbuts and the desired bit.
  7809.  
  7810.             SEE ALSO
  7811.  
  7812.             MOUSERANGESET, MOUSESENSSET
  7813.  
  7814.             EXAMPLE
  7815.  
  7816.             /* enable,show mouse & display status */
  7817.             #include <stdlib.h>
  7818.             #include <conio.h>
  7819.             #include "svgacc.h"
  7820.  
  7821.             void main(void)
  7822.             {
  7823.                int vmode, x, y, mbuts;
  7824.                char buf[100];
  7825.  
  7826.                vmode = videomodeget();
  7827.                if ( !whichvga() || (whichmem() < 512))
  7828.                  exit(1);
  7829.                if ( !whichmouse())
  7830.                  exit(1);
  7831.                res640();
  7832.                mouseenter();
  7833.                mouseshow();
  7834.                while(!kbhit()) {
  7835.                  mousestatus(&x,&y,&mbuts);
  7836.                  sprintf(buf,"X= %4d  Y= %4d  LB= %1d  CB= %1d  RB=
  7837.             %1d\0",x,y,(mbuts & 1),(mbuts & 2),(mbuts & 4));
  7838.                  drwstring(1,15,8,buf,10,32);
  7839.  
  7840.  
  7841.                                                                         125
  7842.  
  7843.  
  7844.  
  7845.  
  7846.  
  7847.                }
  7848.                mousehide();
  7849.                mouseexit();
  7850.                videomodeset(vmode);
  7851.             }
  7852.  
  7853.  
  7854.  
  7855.  
  7856.  
  7857.  
  7858.  
  7859.  
  7860.  
  7861.  
  7862.  
  7863.  
  7864.  
  7865.  
  7866.  
  7867.  
  7868.  
  7869.  
  7870.  
  7871.  
  7872.  
  7873.  
  7874.  
  7875.  
  7876.  
  7877.  
  7878.  
  7879.  
  7880.  
  7881.  
  7882.  
  7883.  
  7884.  
  7885.  
  7886.  
  7887.  
  7888.  
  7889.  
  7890.  
  7891.  
  7892.  
  7893.  
  7894.  
  7895.  
  7896.  
  7897.  
  7898.  
  7899.  
  7900.  
  7901.  
  7902.  
  7903.                                                                         126
  7904.  
  7905.  
  7906.  
  7907.  
  7908.  
  7909.           MOUSESTORAGESIZE
  7910.  
  7911.             PROTOTYPE
  7912.  
  7913.             extern int far mousestoragesize (void)
  7914.  
  7915.             INPUT
  7916.  
  7917.             no input parameters
  7918.  
  7919.             OUTPUT
  7920.  
  7921.             MOUSESTORAGESIZE returns the size of buffer in bytes to store
  7922.             complete mouse status
  7923.  
  7924.             USAGE
  7925.  
  7926.             MOUSESTORAGESIZE determines the proper size buffer to hold the
  7927.             complete mouse status information.  This buffer should be
  7928.             allocated before calling MOUSESAVESTATE.
  7929.  
  7930.             SEE ALSO
  7931.  
  7932.             MOUSERESTORESTATE, MOUSESAVESTATE
  7933.  
  7934.             EXAMPLE
  7935.  
  7936.             /*
  7937.              * return the size in bytes need to save the mouse driver
  7938.             status
  7939.              */
  7940.  
  7941.             #include <stdlib.h>
  7942.             #include <conio.h>
  7943.             #include "svgacc.h"
  7944.  
  7945.             void main(void)
  7946.             {
  7947.                int bufsiz;
  7948.                char buf[50];
  7949.  
  7950.                if ( !whichmouse())
  7951.                  exit(1);
  7952.  
  7953.                bufsiz=mousestoragesize();
  7954.                sprintf(buf,"%d bytes are required to save mouse driver
  7955.             status...",bufsiz);
  7956.                printf("%s", &buf);
  7957.                exit(0);
  7958.             }
  7959.  
  7960.  
  7961.  
  7962.  
  7963.  
  7964.  
  7965.                                                                         127
  7966.  
  7967.  
  7968.  
  7969.  
  7970.  
  7971.           OVERSCANSET
  7972.  
  7973.             PROTOTYPE
  7974.  
  7975.             extern void far overscanset (int colr)
  7976.  
  7977.             INPUT
  7978.  
  7979.             colr - index to color in current palette
  7980.  
  7981.             OUTPUT
  7982.  
  7983.             no value returned
  7984.  
  7985.             USAGE
  7986.  
  7987.             OVERSCANSET sets the overscan region to the specified color.
  7988.             The overscan region is the area between the usable pixel area
  7989.             and the region not scanned by the monitor.  Normally, the
  7990.             overscan is color zero which is defined as black the majority
  7991.             of the time.  The overscan color is reset to zero anytime a
  7992.             RES### function is called.
  7993.  
  7994.             Note: OVERSCANSET always works in the 320x200 resolution.  In
  7995.             the higher resolutions on many common SVGA cards this function
  7996.             is ignored.  Instead, the card always assigns the overscan
  7997.             region to color zero.  Therefore, it is recommended to not use
  7998.             OVERSCANSET, but assign color zero as needed.
  7999.  
  8000.             EXAMPLE
  8001.  
  8002.             /*
  8003.              * set the overscan color to green
  8004.              */
  8005.  
  8006.             #include <stdlib.h>
  8007.             #include <conio.h>
  8008.             #include "svgacc.h"
  8009.  
  8010.             void main(void)
  8011.             {
  8012.                int vmode;
  8013.                vmode = videomodeget();
  8014.                if ( !whichvga() )
  8015.                  exit(1);
  8016.                res320();
  8017.                overscanset(10);
  8018.                getch();
  8019.                videomodeset(vmode);
  8020.                exit(0);
  8021.             }
  8022.  
  8023.  
  8024.  
  8025.  
  8026.  
  8027.                                                                         128
  8028.  
  8029.  
  8030.  
  8031.  
  8032.  
  8033.           PAGEACTIVE
  8034.  
  8035.             PROTOTYPE
  8036.  
  8037.             extern int far pageactive (int page)
  8038.  
  8039.             INPUT
  8040.  
  8041.             page - number of page to make active
  8042.  
  8043.             OUTPUT
  8044.  
  8045.             PAGEACTIVE returns a 1 if successful, 0 if unsuccessful.
  8046.  
  8047.             USAGE
  8048.  
  8049.             PAGEACTIVE sets the active page as specified by page.  It
  8050.             works by creating an offset to be added when any bank
  8051.             switching is performed.  This function does not affect the
  8052.             actual display.  A page is defined as the number of 64K banks
  8053.             necessary to contain the current screen resolution.  For
  8054.             example, 640x480 requires 307,200 bytes which is a little more
  8055.             than 4.5 64K blocks.  One page in this resolution will be 5
  8056.             banks.
  8057.  
  8058.             PAGEACTIVE does not work in 320x200 mode since this mode uses
  8059.             no bank switching.
  8060.  
  8061.             SEE ALSO
  8062.  
  8063.             FILLPAGE, PAGEDISPLAY
  8064.  
  8065.             EXAMPLE
  8066.  
  8067.             /*
  8068.             * Show pageactive (video card needs 1meg to show pages in
  8069.             640x480x256)
  8070.             */
  8071.  
  8072.             #include <stdlib.h>
  8073.             #include <math.h>
  8074.             #include <conio.h>
  8075.             #include "svgacc.h"
  8076.  
  8077.             void main(void)
  8078.             {
  8079.                int vmode,er;
  8080.                char text[]="press a key...";
  8081.                char buf[20];
  8082.                vmode = videomodeget();
  8083.                if ( !whichvga() )
  8084.                  exit(1);
  8085.                if ( whichmem() < 1024)
  8086.                  exit(1);
  8087.  
  8088.  
  8089.                                                                         129
  8090.  
  8091.  
  8092.  
  8093.  
  8094.  
  8095.                if ( !res640() )
  8096.                  exit(1);
  8097.                /* make sure video card supports page flipping */
  8098.                if ( !pagedisplay(0,0,0) ) {
  8099.                  videomodeset(vmode);
  8100.                  exit(1);
  8101.                }
  8102.                er = pageactive(0);
  8103.                fillpage(0);
  8104.                drwstring(1,10,0,text,0,300);
  8105.                sprintf(buf,"Page 0");
  8106.                drwstring(1,10,0,buf,0,0);
  8107.                er = pageactive(1);
  8108.                fillpage(0);
  8109.                drwstring(1,12,0,text,0,300);
  8110.                sprintf(buf,"Page 1");
  8111.                drwstring(1,12,0,buf,0,20);
  8112.                er = pageactive(2);
  8113.                fillpage(0);
  8114.                drwstring(1,13,0,text,0,300);
  8115.                sprintf(buf,"Page 2");
  8116.                drwstring(1,13,0,buf,0,40);
  8117.                er = pageactive(0);
  8118.                er = pagedisplay(0,0,0);
  8119.                getch();
  8120.                er = pagedisplay(0,0,1);
  8121.                getch();
  8122.                er = pagedisplay(0,0,2);
  8123.                getch();
  8124.                videomodeset(vmode);
  8125.                exit(0);
  8126.             }
  8127.  
  8128.  
  8129.  
  8130.  
  8131.  
  8132.  
  8133.  
  8134.  
  8135.  
  8136.  
  8137.  
  8138.  
  8139.  
  8140.  
  8141.  
  8142.  
  8143.  
  8144.  
  8145.  
  8146.  
  8147.  
  8148.  
  8149.  
  8150.  
  8151.                                                                         130
  8152.  
  8153.  
  8154.  
  8155.  
  8156.  
  8157.           PAGEDISPLAY
  8158.  
  8159.             PROTOTYPE
  8160.  
  8161.             extern int far pagedisplay (int x, int y, int page)
  8162.  
  8163.             INPUT
  8164.  
  8165.             x, y - coordinate to place at top, left of display
  8166.             page - number of page to make active
  8167.  
  8168.             OUTPUT
  8169.  
  8170.             PAGEDISPLAY returns a 1 if successful, 0 if unsuccessful.
  8171.  
  8172.             USAGE
  8173.  
  8174.             PAGEDISPLAY tells the video card where in video memory to
  8175.             begin the display.  This display offset is calculated from the
  8176.             specified page, x and y.  This is done by multiplying y times
  8177.             the width of the current resolution, adding x and then adding
  8178.             the appropriate number of 64K blocks for page.  X, y and page
  8179.             must all be positive numbers, but are otherwise not
  8180.             restricted.  The display will wrap if the values are
  8181.             abnormally large.  Wrapping will happen from side to side as
  8182.             well as from top of memory to bottom of memory.
  8183.  
  8184.             PAGEDISPLAY does not work in 320x200 mode since this mode uses
  8185.             no bank switching.  In addition, older models of some SVGA
  8186.             cards operating in native mode do not support paging.  In this
  8187.             library these cards are: Acumos, Ahead version A, Everex and
  8188.             Genoa.  To ensure compatibility, a program should make a call
  8189.             similar to:
  8190.  
  8191.                if ( !pagedisplay(0,0,0) )
  8192.                  printf("PAGING NOT SUPPORTED\n");
  8193.  
  8194.             Note: SVGA cards by ATI Technologies appear to ignore bit 4
  8195.             (counting from 0 to 19) in its linear addressing mode and
  8196.             assume it is zero.  Therefore, bit 4 of the x parameter will
  8197.             be ignored by ATI chipsets.
  8198.  
  8199.             SEE ALSO
  8200.  
  8201.             FILLPAGE, PAGEACTIVE
  8202.  
  8203.             EXAMPLE
  8204.  
  8205.             See PAGEACTIVE
  8206.  
  8207.  
  8208.  
  8209.  
  8210.  
  8211.  
  8212.  
  8213.                                                                         131
  8214.  
  8215.  
  8216.  
  8217.  
  8218.  
  8219.           PALCHGAUTO
  8220.  
  8221.             PROTOTYPE
  8222.  
  8223.             extern void far palchgauto (RGB far *pal, RGB far *newpal, int
  8224.             firstcolr, int lastcolr, int speed)
  8225.  
  8226.             INPUT
  8227.  
  8228.             pal - initial palette
  8229.             newpal - new palette
  8230.             firstcolr - index into palette where change will begin
  8231.             lastcolr - index into palette where change will end
  8232.             speed - speed of change
  8233.  
  8234.             OUTPUT
  8235.  
  8236.             no value returned
  8237.  
  8238.             USAGE
  8239.  
  8240.             PALCHGAUTO smoothly fades the colors between firstcolr and
  8241.             lastcolr from the palette pal to newpal.  The speed of the
  8242.             fade is set by speed which is percentage change between each
  8243.             step of the fade.  Only values between 1 and 128 are valid
  8244.             where 1 represents a one percent change between steps and 128
  8245.             (80 hex) represents fifty percent change between steps.  A
  8246.             speed of 128 would then have only two steps.  A speed outside
  8247.             of the valid range causes the function to immediately return
  8248.             without making any changes.  The time required to accomplish
  8249.             the entire fade is approximately equal to 0.033 seconds times
  8250.             256 divided by speed.  PALCHGAUTO does not modify either pal
  8251.             or newpal.
  8252.  
  8253.             SEE ALSO
  8254.  
  8255.             PALCHGSTEP, PALDIMSTEP, PALIOAUTO
  8256.  
  8257.             EXAMPLE
  8258.  
  8259.             /*
  8260.              * autofade from one palette to another and back again
  8261.              */
  8262.  
  8263.             #include <stdlib.h>
  8264.             #include <conio.h>
  8265.             #include "svgacc.h"
  8266.  
  8267.             void main(void)
  8268.             {
  8269.                int vmode, colr, y, i, index;
  8270.                PaletteData orgpal, newpal;
  8271.  
  8272.                vmode = videomodeget();
  8273.  
  8274.  
  8275.                                                                         132
  8276.  
  8277.  
  8278.  
  8279.  
  8280.  
  8281.                if ( !whichvga() )
  8282.                  exit(1);
  8283.                if ( whichmem() < 512)
  8284.                  exit(1);
  8285.                res640();
  8286.                palget(orgpal,0,255);
  8287.                for (index=0;index<256;index++) {
  8288.                  newpal[index].r = index / 4;
  8289.                  newpal[index].g = index / 4;
  8290.                  newpal[index].b = index / 4;
  8291.                }
  8292.                colr = 0;
  8293.                for (y=0;y<480;y++) {
  8294.                  drwline(1,colr++,0,y,639,y);
  8295.                  if (colr>255)
  8296.                     colr = 0;
  8297.                }
  8298.                palchgauto(orgpal,newpal,0,255,2);
  8299.                palchgauto(newpal,orgpal,0,255,2);
  8300.                getch();
  8301.                videomodeset(vmode);
  8302.                exit(0);
  8303.             }
  8304.  
  8305.  
  8306.  
  8307.  
  8308.  
  8309.  
  8310.  
  8311.  
  8312.  
  8313.  
  8314.  
  8315.  
  8316.  
  8317.  
  8318.  
  8319.  
  8320.  
  8321.  
  8322.  
  8323.  
  8324.  
  8325.  
  8326.  
  8327.  
  8328.  
  8329.  
  8330.  
  8331.  
  8332.  
  8333.  
  8334.  
  8335.  
  8336.  
  8337.                                                                         133
  8338.  
  8339.  
  8340.  
  8341.  
  8342.  
  8343.           PALCHGSTEP
  8344.  
  8345.             PROTOTYPE
  8346.  
  8347.             extern void far palchgstep (RGB far *pal, RGB far *newpal, int
  8348.             firstcolr, int lastcolr, int percent)
  8349.  
  8350.             INPUT
  8351.  
  8352.             pal - initial palette
  8353.             newpal - new palette
  8354.             firstcolr - index into palette where change will begin
  8355.             lastcolr - index into palette where change will end
  8356.             percent - percent step from current palette to new palette
  8357.  
  8358.             OUTPUT
  8359.  
  8360.             no value returned
  8361.  
  8362.             USAGE
  8363.  
  8364.             PALCHGSTEP changes the palette colors between firstcolr and
  8365.             lastcolr by percent from pal to newpal.  This function works
  8366.             very much like PALCHGAUTO except it only takes a single step
  8367.             and returns.  The step taken is a percentage specified by
  8368.             Percent where 256 (100 hex) is a 100 percent change.  The
  8369.             valid range for Percent is 0 to 256.  Values beyond this range
  8370.             cause the function to immediately return without making any
  8371.             changes.  A loop from 4 to 256 by fours using PALCHGSTEP would
  8372.             have similar results as PALCHGAUTO with a speed of 4.  Neither
  8373.             pal, nor newpal are modified.
  8374.  
  8375.             SEE ALSO
  8376.  
  8377.             PALCHGAUTO, PALDIMSTEP, PALIOAUTO
  8378.  
  8379.             EXAMPLE
  8380.  
  8381.             /*
  8382.              * step fade from one palette to another and back again
  8383.              */
  8384.  
  8385.             #include <stdlib.h>
  8386.             #include <conio.h>
  8387.             #include "svgacc.h"
  8388.  
  8389.             void main(void)
  8390.             {
  8391.                int vmode, colr, y, i, index;
  8392.                PaletteData orgpal, newpal;
  8393.  
  8394.                vmode = videomodeget();
  8395.                if ( !whichvga() )
  8396.                  exit(1);
  8397.  
  8398.  
  8399.                                                                         134
  8400.  
  8401.  
  8402.  
  8403.  
  8404.  
  8405.                if ( whichmem() < 512)
  8406.                  exit(1);
  8407.                res640();
  8408.  
  8409.                palget(orgpal,0,255);
  8410.                for (index=0;index<256;index++)
  8411.                {
  8412.                  newpal[index].r = index / 4;
  8413.                  newpal[index].g = index / 4;
  8414.                  newpal[index].b = index / 4;
  8415.                }
  8416.                colr = 0;
  8417.                for (y=0;y<480;y++)
  8418.                {
  8419.                  drwline(1,colr++,0,y,639,y);
  8420.                  if (colr>255)
  8421.                     colr = 0;
  8422.                }
  8423.                for (index=0;index<256;index++)
  8424.                {
  8425.                  palchgstep(orgpal,newpal,0,255,index);
  8426.                }
  8427.                for (index=256;index>=-1;index--)
  8428.                {
  8429.                  palchgstep(orgpal,newpal,0,255,index);
  8430.                }
  8431.                getch();
  8432.                videomodeset(vmode);
  8433.                exit(0);
  8434.             }
  8435.  
  8436.  
  8437.  
  8438.  
  8439.  
  8440.  
  8441.  
  8442.  
  8443.  
  8444.  
  8445.  
  8446.  
  8447.  
  8448.  
  8449.  
  8450.  
  8451.  
  8452.  
  8453.  
  8454.  
  8455.  
  8456.  
  8457.  
  8458.  
  8459.  
  8460.  
  8461.                                                                         135
  8462.  
  8463.  
  8464.  
  8465.  
  8466.  
  8467.           PALCOPY
  8468.  
  8469.             PROTOTYPE
  8470.  
  8471.             extern void far palcopy (RGB far *srcpal, RGB far *destpal,
  8472.             int firstcolr, int lastcolr)
  8473.  
  8474.             INPUT
  8475.  
  8476.             srcpal - source palette
  8477.             firstcolr - index into palette where copy will begin
  8478.             lastcolr - index into palette where copy will end
  8479.  
  8480.             OUTPUT
  8481.  
  8482.             no value returned
  8483.             destpal - copy of srcpal
  8484.  
  8485.             USAGE
  8486.  
  8487.             PALCOPY quickly copies a source palette into a second palette
  8488.             array.  Destpal must be previously allocated.  A portion of a
  8489.             palette may be copied by specifying first and last colors.  If
  8490.             firstcolr is greater than lastcolr, no copy will occur.
  8491.  
  8492.             SEE ALSO
  8493.  
  8494.             BYTECOPY
  8495.  
  8496.             EXAMPLE
  8497.  
  8498.             /*
  8499.              * create a color palette(grayscale) and copy it to a palette
  8500.              * of a different name
  8501.              */
  8502.  
  8503.             #include <stdlib.h>
  8504.             #include <conio.h>
  8505.             #include "svgacc.h"
  8506.  
  8507.             void main(void)
  8508.             {
  8509.                int vmode,colr,y,i,index;
  8510.                PaletteData pal, newpal;
  8511.  
  8512.                vmode = videomodeget();
  8513.                if ( !whichvga() )
  8514.                  exit(1);
  8515.                if ( whichmem() < 512)
  8516.                  exit(1);
  8517.                if ( !res640() )
  8518.                  exit(1);
  8519.                for (index=0;index<256;index++) {
  8520.                  pal[index].r = index / 4;
  8521.  
  8522.  
  8523.                                                                         136
  8524.  
  8525.  
  8526.  
  8527.  
  8528.  
  8529.                  pal[index].g = index / 4;
  8530.                  pal[index].b = index / 4;
  8531.                }
  8532.                colr = 0;
  8533.                palcopy(pal,newpal,0,255);
  8534.                for (y=0;y<480;y++) {
  8535.                  drwline(1,colr++,0,y,639,y);
  8536.                  if (colr>255)
  8537.                     colr = 0;
  8538.                }
  8539.                palset(newpal,0,255);
  8540.                getch();
  8541.                videomodeset(vmode);
  8542.                exit(0);
  8543.             }
  8544.  
  8545.  
  8546.  
  8547.  
  8548.  
  8549.  
  8550.  
  8551.  
  8552.  
  8553.  
  8554.  
  8555.  
  8556.  
  8557.  
  8558.  
  8559.  
  8560.  
  8561.  
  8562.  
  8563.  
  8564.  
  8565.  
  8566.  
  8567.  
  8568.  
  8569.  
  8570.  
  8571.  
  8572.  
  8573.  
  8574.  
  8575.  
  8576.  
  8577.  
  8578.  
  8579.  
  8580.  
  8581.  
  8582.  
  8583.  
  8584.  
  8585.                                                                         137
  8586.  
  8587.  
  8588.  
  8589.  
  8590.  
  8591.           PALDIMSTEP
  8592.  
  8593.             PROTOTYPE
  8594.  
  8595.             extern void far paldimstep (RGB far *pal, int firstcolr, int
  8596.             lastcolr, int percent)
  8597.  
  8598.             INPUT
  8599.  
  8600.             pal - initial palette
  8601.             firstcolr - index into palette where dim will begin
  8602.             lastcolr - index into palette where dim will end
  8603.             percent - percent step from current palette to black
  8604.  
  8605.             OUTPUT
  8606.  
  8607.             no value returned
  8608.  
  8609.             USAGE
  8610.  
  8611.             PALDIMSTEP fades the specified palette to black by the given
  8612.             percentage between firstcolr and lastcolr.  The percentage
  8613.             step from pal to black is specified by percent where 256 (100
  8614.             hex) is full black.  The valid range for Percent is 0 to 256.
  8615.             Values beyond this range cause the function to immediately
  8616.             return without making any changes.  pal is not modified.
  8617.  
  8618.             SEE ALSO
  8619.  
  8620.             PALCHGAUTO, PALCHGSTEP, PALIOAUTO
  8621.  
  8622.             EXAMPLE
  8623.  
  8624.             /*
  8625.              * step dim from a palette to black and back again
  8626.              */
  8627.  
  8628.             #include <stdlib.h>
  8629.             #include <conio.h>
  8630.             #include "svgacc.h"
  8631.  
  8632.             void main(void)
  8633.             {
  8634.                int vmode;
  8635.                int colr;
  8636.                int y;
  8637.                int i;
  8638.                int index;
  8639.                PaletteData orgpal;
  8640.  
  8641.                vmode = videomodeget();
  8642.                if ( !whichvga() )
  8643.                  exit(1);
  8644.                if ( whichmem() < 512)
  8645.  
  8646.  
  8647.                                                                         138
  8648.  
  8649.  
  8650.  
  8651.  
  8652.  
  8653.                  exit(1);
  8654.                res640();
  8655.                palget(orgpal,0,255);
  8656.                colr = 0;
  8657.                for (y=0;y<480;y++)
  8658.                {
  8659.                  drwline(1,colr++,0,y,639,y);
  8660.                  if (colr>255)
  8661.                     colr = 0;
  8662.                }
  8663.                for (index=0;index<256;index++)
  8664.                {
  8665.                  paldimstep(orgpal,0,255,index);
  8666.                }
  8667.                for (index=256;index>=-1;index--)
  8668.                {
  8669.                  paldimstep(orgpal,0,255,index);
  8670.                }
  8671.                getch();
  8672.                videomodeset(vmode);
  8673.                exit(0);
  8674.             }
  8675.  
  8676.  
  8677.  
  8678.  
  8679.  
  8680.  
  8681.  
  8682.  
  8683.  
  8684.  
  8685.  
  8686.  
  8687.  
  8688.  
  8689.  
  8690.  
  8691.  
  8692.  
  8693.  
  8694.  
  8695.  
  8696.  
  8697.  
  8698.  
  8699.  
  8700.  
  8701.  
  8702.  
  8703.  
  8704.  
  8705.  
  8706.  
  8707.  
  8708.  
  8709.                                                                         139
  8710.  
  8711.  
  8712.  
  8713.  
  8714.  
  8715.           PALGET
  8716.  
  8717.             PROTOTYPE
  8718.  
  8719.             extern void far palget (RGB far *pal, int firstcolr, int
  8720.             lastcolr)
  8721.  
  8722.             INPUT
  8723.  
  8724.             firstcolr - index into palette where get will begin
  8725.             lastcolr - index into palette where get will end
  8726.  
  8727.             OUTPUT
  8728.  
  8729.             pal - copy of the current palette in the specified range
  8730.  
  8731.             USAGE
  8732.  
  8733.             PALGET returns in pal the colors from the current palette
  8734.             between firstcolr and lastcolr.  Only colors in the specified
  8735.             range are returned and all others in pal are unchanged.  Pal
  8736.             must be 768 bytes in length despite the number of colors
  8737.             retrieved.
  8738.  
  8739.             SEE ALSO
  8740.  
  8741.             PALROTATE, PALSET
  8742.  
  8743.             EXAMPLE
  8744.  
  8745.             See PALCHGAUTO
  8746.  
  8747.  
  8748.  
  8749.  
  8750.  
  8751.  
  8752.  
  8753.  
  8754.  
  8755.  
  8756.  
  8757.  
  8758.  
  8759.  
  8760.  
  8761.  
  8762.  
  8763.  
  8764.  
  8765.  
  8766.  
  8767.  
  8768.  
  8769.  
  8770.  
  8771.                                                                         140
  8772.  
  8773.  
  8774.  
  8775.  
  8776.  
  8777.           PALIOAUTO
  8778.  
  8779.             PROTOTYPE
  8780.  
  8781.             extern void far palioauto (RGB far *pal, int firstcolr, int
  8782.             lastcolr, int speed)
  8783.  
  8784.             INPUT
  8785.  
  8786.             pal - initial palette
  8787.             firstcolr - index into palette where fade will begin
  8788.             lastcolr - index into palette where fade will end
  8789.             speed - speed of fade
  8790.  
  8791.             OUTPUT
  8792.  
  8793.             no value returned
  8794.  
  8795.             USAGE
  8796.  
  8797.             PALIOAUTO smoothly fades the colors between firstcolr and
  8798.             lastcolr of pal to or from solid black.  The speed of the fade
  8799.             is set by speed which is the percentage change between each
  8800.             step of the fade.  A positive speed corresponds to fading from
  8801.             pal to black and a negative speed fades from black to Pal.
  8802.             Only values between -128 and +128 are valid where  1
  8803.             represents a one percent change between steps and  128 ( 80
  8804.             hex) represents fifty percent change between steps.  A speed
  8805.             of 128 would then have only two steps.  A speed outside of the
  8806.             valid range causes the function to immediately return without
  8807.             making any changes.  The time required to accomplish the
  8808.             entire fade is approximately equal to 0.033 seconds times 256
  8809.             divided by speed.  PALIOAUTO does not modify pal.
  8810.  
  8811.             SEE ALSO
  8812.  
  8813.             PALCHGAUTO, PALCHGSTEP, PALDIMSTEP
  8814.  
  8815.             EXAMPLE
  8816.  
  8817.             /*
  8818.              * autofade a palette to black and back again
  8819.              */
  8820.  
  8821.             #include <stdlib.h>
  8822.             #include <conio.h>
  8823.             #include "svgacc.h"
  8824.  
  8825.             void main(void)
  8826.             {
  8827.                int vmode, colr, y;
  8828.                PaletteData orgpal;
  8829.  
  8830.                vmode = videomodeget();
  8831.  
  8832.  
  8833.                                                                         141
  8834.  
  8835.  
  8836.  
  8837.  
  8838.  
  8839.                if ( !whichvga() )
  8840.                  exit(1);
  8841.                if ( whichmem() < 512)
  8842.                  exit(1);
  8843.                res640();
  8844.                colr = 0;
  8845.                palget(orgpal,0,255);
  8846.                for (y=0;y<480;y++) {
  8847.                  drwline(1,colr++,0,y,639,y);
  8848.                  if (colr>255)
  8849.                     colr = 0;
  8850.                }
  8851.                palioauto(orgpal,0,255,-2);
  8852.                palioauto(orgpal,0,255,2);
  8853.                getch();
  8854.                videomodeset(vmode);
  8855.                exit(0);
  8856.             }
  8857.  
  8858.  
  8859.  
  8860.  
  8861.  
  8862.  
  8863.  
  8864.  
  8865.  
  8866.  
  8867.  
  8868.  
  8869.  
  8870.  
  8871.  
  8872.  
  8873.  
  8874.  
  8875.  
  8876.  
  8877.  
  8878.  
  8879.  
  8880.  
  8881.  
  8882.  
  8883.  
  8884.  
  8885.  
  8886.  
  8887.  
  8888.  
  8889.  
  8890.  
  8891.  
  8892.  
  8893.  
  8894.  
  8895.                                                                         142
  8896.  
  8897.  
  8898.  
  8899.  
  8900.  
  8901.           PALROTATE
  8902.  
  8903.             PROTOTYPE
  8904.  
  8905.             extern void far palrotate (RGB far *pal, int firstcolr, int
  8906.             lastcolr, int shift)
  8907.  
  8908.             INPUT
  8909.  
  8910.             pal - PaletteData pointer to current palette
  8911.             firstcolr - index into palette where shift will begin
  8912.             lastcolr - index into palette where shift will end
  8913.             shift - number of locations to shift colors
  8914.  
  8915.             OUTPUT
  8916.  
  8917.             no value returned
  8918.  
  8919.             USAGE
  8920.  
  8921.             PALROTATE shifts the colors in pal between firstcolr and
  8922.             lastcolr by a given number of locations and sets this new
  8923.             palette.  The number of locations the colors are moved is
  8924.             specified by shift which is between 1 and 256.  Pal is not
  8925.             modified by PALROTATE.
  8926.  
  8927.             SEE ALSO
  8928.  
  8929.             PALGET, PALSET
  8930.  
  8931.             EXAMPLE
  8932.  
  8933.             /*
  8934.              * rotate a few palette entries around
  8935.              */
  8936.  
  8937.             #include <stdlib.h>
  8938.             #include <conio.h>
  8939.             #include "svgacc.h"
  8940.  
  8941.             void main(void)
  8942.             {
  8943.                int vmode, colr, y, i, index;
  8944.                PaletteData orgpal;
  8945.  
  8946.                vmode = videomodeget();
  8947.                if ( !whichvga() )
  8948.                  exit(1);
  8949.                if ( whichmem() < 512)
  8950.                  exit(1);
  8951.                res640();
  8952.                colr = 0;
  8953.                palget(orgpal,0,255);
  8954.                for (y=0;y<480;y++) {
  8955.  
  8956.  
  8957.                                                                         143
  8958.  
  8959.  
  8960.  
  8961.  
  8962.  
  8963.                  drwline(1,colr++,0,y,639,y);
  8964.                  if (colr>255)
  8965.                     colr = 0;
  8966.                }
  8967.                for (i=0;i<200;i++) {
  8968.                  palrotate(orgpal,1,127,1);
  8969.                  palget(orgpal,0,255);
  8970.                }
  8971.                getch();
  8972.                videomodeset(vmode);
  8973.                exit(0);
  8974.             }
  8975.  
  8976.  
  8977.  
  8978.  
  8979.  
  8980.  
  8981.  
  8982.  
  8983.  
  8984.  
  8985.  
  8986.  
  8987.  
  8988.  
  8989.  
  8990.  
  8991.  
  8992.  
  8993.  
  8994.  
  8995.  
  8996.  
  8997.  
  8998.  
  8999.  
  9000.  
  9001.  
  9002.  
  9003.  
  9004.  
  9005.  
  9006.  
  9007.  
  9008.  
  9009.  
  9010.  
  9011.  
  9012.  
  9013.  
  9014.  
  9015.  
  9016.  
  9017.  
  9018.  
  9019.                                                                         144
  9020.  
  9021.  
  9022.  
  9023.  
  9024.  
  9025.           PALSET
  9026.  
  9027.             PROTOTYPE
  9028.  
  9029.             extern void far palset (RGB far *pal, int firstcolr, int
  9030.             lastcolr)
  9031.  
  9032.             INPUT
  9033.  
  9034.             pal - palette to set
  9035.             firstcolr - index into palette where set will begin
  9036.             lastcolr - index into palette where set will end
  9037.  
  9038.             OUTPUT
  9039.  
  9040.             no value returned
  9041.  
  9042.             USAGE
  9043.  
  9044.             PALSET sets the specified range of colors in the current
  9045.             palette with the corresponding range in the palette pal.
  9046.  
  9047.             SEE ALSO
  9048.  
  9049.             PALGET
  9050.  
  9051.             EXAMPLE
  9052.  
  9053.             See PALCOPY
  9054.  
  9055.  
  9056.  
  9057.  
  9058.  
  9059.  
  9060.  
  9061.  
  9062.  
  9063.  
  9064.  
  9065.  
  9066.  
  9067.  
  9068.  
  9069.  
  9070.  
  9071.  
  9072.  
  9073.  
  9074.  
  9075.  
  9076.  
  9077.  
  9078.  
  9079.  
  9080.  
  9081.                                                                         145
  9082.  
  9083.  
  9084.  
  9085.  
  9086.  
  9087.           PCXGETINFO
  9088.  
  9089.             PROTOTYPE
  9090.  
  9091.             extern int far pcxgetinfo (const char far *name, int far
  9092.                *pcxxsize, int far *pcxysize, int far *numcolors, RGB far
  9093.                *pal)
  9094.  
  9095.             INPUT
  9096.  
  9097.             name - char pointer to the filename of the PCX image to read
  9098.  
  9099.             OUTPUT
  9100.  
  9101.             PCXGETINFO returns 1 if successful, error code otherwise.
  9102.             pcxxsize - width in pixels of the image
  9103.             pcxysize - height in pixels of the image
  9104.             numcolors - number of colors in the image palette
  9105.             palette - copy of image palette
  9106.  
  9107.             USAGE
  9108.  
  9109.             PCXGETINFO reads name and returns the characteristics of the
  9110.             image.  The dimensions of the image are returned in pcxxsize,
  9111.             pcxysize.  The number of colors in the image's palette is
  9112.             returned in numcolors and the palette is returned in palette.
  9113.             Although the image's palette may contain less than 256 colors,
  9114.             palette must be 768 bytes in length.  The image's palette will
  9115.             begin with the first color in Palette.
  9116.  
  9117.             PCX version 3.0 is the only specification for 256 color
  9118.             images.  Therefore, only version 3.0 PCX files are accepted.
  9119.  
  9120.             If PCXGETINFO determines that Filename is a satisfactory file,
  9121.             the function will return a one.  Otherwise, the function will
  9122.             return one of several error codes as listed below:
  9123.  
  9124.             0 =  does not exist or there is some disk I/O problem
  9125.             -1 = not a version 3.0 PCX file
  9126.             -2 = not run-length-encoded
  9127.             -3 = general error
  9128.  
  9129.             SEE ALSO
  9130.  
  9131.             PCXMAKE, PCXPUT
  9132.  
  9133.             EXAMPLE
  9134.  
  9135.             /*
  9136.              * show the info on the 'zephyr.pcx' PCX file
  9137.              */
  9138.  
  9139.             #include <stdlib.h>
  9140.             #include <conio.h>
  9141.  
  9142.  
  9143.                                                                         146
  9144.  
  9145.  
  9146.  
  9147.  
  9148.  
  9149.             #include "svgacc.h"
  9150.  
  9151.             void main(void)
  9152.             {
  9153.                int vmode, xsize, ysize, numcol, ok;
  9154.                int i, darkcolor, britecolor, currcolor;
  9155.                PaletteData pcxpal;
  9156.                char buf[80];
  9157.                char fname[] = "zephyr.pcx";
  9158.  
  9159.                vmode = videomodeget();
  9160.                if ( !whichvga() || (whichmem() < 512))
  9161.                  exit(1);
  9162.  
  9163.                ok = pcxgetinfo(fname,&xsize,&ysize,&numcol,pcxpal);
  9164.  
  9165.                if (ok == 1) {
  9166.                  if ( !res640() )
  9167.                     exit(1);
  9168.  
  9169.                  /* we have an unknown 8 bit palette and we must cut it
  9170.             down to
  9171.                     6 bits and find the brightest and darkest colors */
  9172.                  darkcolor = 0 + 0 + 0;
  9173.                  britecolor = 63 + 63 + 63;
  9174.                  for(i=0;i<255;i++) {
  9175.                     pcxpal[i].r >>= 2;
  9176.                     pcxpal[i].g >>= 2;
  9177.                     pcxpal[i].b >>= 2;
  9178.                     currcolor = pcxpal[i].r + pcxpal[i].g + pcxpal[i].b;
  9179.                     if (currcolor > darkcolor)
  9180.                       darkcolor = currcolor;
  9181.                     if (currcolor < britecolor)
  9182.                       britecolor = currcolor;
  9183.                  }
  9184.                  palset(pcxpal,0,255);
  9185.                  fillscreen(darkcolor);
  9186.                  sprintf(buf,"'%s' is identified as a v3.0 PCX
  9187.             image.",fname);
  9188.                  drwstring(1,britecolor,darkcolor,buf,0,0);
  9189.                  sprintf(buf,"Dimensions are: %d pixels wide and %d pixels
  9190.             high.",xsize,ysize);
  9191.                  drwstring(1,britecolor,darkcolor,buf,0,16);
  9192.                  sprintf(buf,"Number of colors: %d.",numcol);
  9193.                  drwstring(1,britecolor,darkcolor,buf,0,32);
  9194.                  pcxput(SET,0,100,fname);
  9195.                } else {
  9196.                  printf("error in pcx file, error code: %d\n",ok);
  9197.                }
  9198.                getch();
  9199.                videomodeset(vmode);
  9200.             }
  9201.  
  9202.  
  9203.  
  9204.  
  9205.                                                                         147
  9206.  
  9207.  
  9208.  
  9209.  
  9210.  
  9211.           PCXMAKE
  9212.  
  9213.             PROTOTYPE
  9214.  
  9215.             extern int far pcxmake (int x1, int y1, int x2, int y2, const
  9216.             char far *name)
  9217.  
  9218.             INPUT
  9219.  
  9220.             x1, y1 - the location of the top, left corner of the image
  9221.             x2, y2 - the bottom, right corner of the image
  9222.             name - filename to store the PCX image
  9223.  
  9224.             OUTPUT
  9225.  
  9226.             PCXMAKE returns a 1 if successful, 0 if unsuccessful.
  9227.  
  9228.             USAGE
  9229.  
  9230.             PcxMAKE takes the bitmap enclosed in the box defined by (x1,
  9231.             y1) - (x2, y2) and writes a PCX with the filename specified by
  9232.             name.  The resulting file uses the PCX version 3.0
  9233.             specifications.  The values x1, y1, x2 and y2 must be valid
  9234.             coordinates on the currently active page.  Name may specify a
  9235.             full path and drive letter, if necessary.
  9236.  
  9237.             If PCXPUT encounters no problems, the function will return a
  9238.             one.  Otherwise, the function will return one of several error
  9239.             codes concerning Filename$ as listed below:
  9240.  
  9241.             0 =  disk I/O problem
  9242.             -1 = coordinates out of range
  9243.  
  9244.             SEE ALSO
  9245.  
  9246.             PCXGETINFO, PCXPUT
  9247.  
  9248.             EXAMPLE
  9249.  
  9250.             /*
  9251.              * Make a simple PCX file
  9252.              */
  9253.  
  9254.             #include <stdlib.h>
  9255.             #include <conio.h>
  9256.             #include "svgacc.h"
  9257.             #define randnum(size) (rand() % (int)(size))
  9258.  
  9259.             void main(void)
  9260.             {
  9261.                int vmode,colr,num,i;
  9262.                int x1,y1,x2,y2,er;
  9263.                char text[]="This PCX was made using Zephyr Software's
  9264.             PCXMAKE function!";
  9265.  
  9266.  
  9267.                                                                         148
  9268.  
  9269.  
  9270.  
  9271.  
  9272.  
  9273.                char fname[]="test.pcx";
  9274.  
  9275.                vmode = videomodeget();
  9276.                if ( !whichvga() || (whichmem() < 512))
  9277.                  exit(1);
  9278.                if ( !res640() )
  9279.                  exit(1);
  9280.                fillscreen(10);
  9281.                colr = 1;
  9282.                for(i=0;i<200;i++) {
  9283.                  x1 = randnum(maxx);
  9284.                  y1 = randnum(maxy);
  9285.                  x2 = randnum(maxx);
  9286.                  y2 = randnum(maxy);
  9287.                  drwline(1,colr++,x1,y1,x2,y2);
  9288.                  if (colr>15)
  9289.                     colr = 1;
  9290.                }
  9291.                drwbox(SET,15,0,0,maxx,maxy);
  9292.                drwstring(1,15,0,text,60,10);
  9293.                er = pcxmake(0,0,maxx,maxy,fname);
  9294.                if (er != 1 ) {
  9295.                  videomodeset(vmode);
  9296.                  exit(1);
  9297.                }
  9298.  
  9299.                videomodeset(vmode);
  9300.                exit(0);
  9301.             } 
  9302.  
  9303.  
  9304.  
  9305.  
  9306.  
  9307.  
  9308.  
  9309.  
  9310.  
  9311.  
  9312.  
  9313.  
  9314.  
  9315.  
  9316.  
  9317.  
  9318.  
  9319.  
  9320.  
  9321.  
  9322.  
  9323.  
  9324.  
  9325.  
  9326.  
  9327.  
  9328.  
  9329.                                                                         149
  9330.  
  9331.  
  9332.  
  9333.  
  9334.  
  9335.           PCXPUT
  9336.  
  9337.             PROTOTYPE
  9338.  
  9339.             extern int far pcxput (PixelMode mode, int xloc, int yloc,
  9340.             const char far *name)
  9341.  
  9342.             INPUT
  9343.  
  9344.             mode - pixel write mode
  9345.             xloc, yloc - the location of the top, left corner of the PCX
  9346.             image
  9347.             name - char pointer to filename of the PCX image to read
  9348.  
  9349.             OUTPUT
  9350.  
  9351.             PCXPUT returns 1 if successful, error code otherwise.
  9352.  
  9353.             USAGE
  9354.  
  9355.             PCXPUT reads the PCX image from name and places it on the
  9356.             screen with the top, left corner at xloc, yloc.  The image is
  9357.             automatically clipped to the currently defined viewport.  The
  9358.             image's palette should be previously obtained by using
  9359.             PCXGETINFO.
  9360.  
  9361.             PCX version 3.0 is the only specification for 256 color
  9362.             images.  Therefore, only version 3.0 PCX files are accepted.
  9363.  
  9364.             If PCXPUT encounters no problems, the function will return a
  9365.             one.  Otherwise, the function will return one of several error
  9366.             codes as listed below:
  9367.  
  9368.             0 =  does not exist or there is some disk I/O problem
  9369.             -1 = not a version 3.0 PCX file
  9370.             -2 = not run-length-encoded
  9371.             -3 = general error
  9372.  
  9373.             SEE ALSO
  9374.  
  9375.             PCXGETINFO, PCXMAKE, SETVIEW
  9376.  
  9377.             EXAMPLE
  9378.  
  9379.             See PCXGETINFO
  9380.  
  9381.  
  9382.  
  9383.  
  9384.  
  9385.  
  9386.  
  9387.  
  9388.  
  9389.  
  9390.  
  9391.                                                                         150
  9392.  
  9393.  
  9394.  
  9395.  
  9396.  
  9397.           RES320
  9398.  
  9399.             PROTOTYPE
  9400.  
  9401.             extern int far res320 (void)
  9402.  
  9403.             INPUT
  9404.  
  9405.             no input parameters
  9406.  
  9407.             OUTPUT
  9408.  
  9409.             RES320 always returns a 1.
  9410.  
  9411.             USAGE
  9412.  
  9413.             RES320 sets video mode 0x13 which is the industry standard
  9414.             320x200 graphics mode with 256 colors.  This function can be
  9415.             called without calling WHICHVGA first as this function
  9416.             requires only that a VGA card is present, not a Super VGA
  9417.             card.  If a VGA is not present, the system may crash.
  9418.  
  9419.             SEE ALSO
  9420.  
  9421.             RES640, RES640L, RES800, RES1024, RES1280, WHICHVGA
  9422.  
  9423.             EXAMPLE
  9424.  
  9425.             /*
  9426.              * set video mode to 320x200x256
  9427.              */
  9428.  
  9429.             #include <stdlib.h>
  9430.             #include <conio.h>
  9431.             #include "svgacc.h"
  9432.  
  9433.             void main(void)
  9434.             {
  9435.                int vmode;
  9436.  
  9437.                vmode = videomodeget();
  9438.                if ( !whichvga() )
  9439.                  exit();
  9440.                res320();
  9441.                drwstring(1,7,0,"this is the 320x200x256 video
  9442.             mode...",0,0);
  9443.                getch();
  9444.                videomodeset(vmode);
  9445.                exit(0);
  9446.             }
  9447.  
  9448.  
  9449.  
  9450.  
  9451.  
  9452.  
  9453.                                                                         151
  9454.  
  9455.  
  9456.  
  9457.  
  9458.  
  9459.           RES640
  9460.  
  9461.             PROTOTYPE
  9462.  
  9463.             extern int far res640 (void)
  9464.  
  9465.             INPUT
  9466.  
  9467.             no input parameters
  9468.  
  9469.             OUTPUT
  9470.  
  9471.             RES640 returns 1 if successful, 0 otherwise.
  9472.  
  9473.             USAGE
  9474.  
  9475.             RES640 sets the video mode to 640x480 graphics mode with 256
  9476.             colors.  This function requires that a Super VGA card with at
  9477.             least 512K of video memory be present.  Also, WHICHVGA must be
  9478.             called first or the function will fail without changing the
  9479.             video mode.  If the video card does not have sufficient
  9480.             memory, RES640 will return without changing the video mode.
  9481.  
  9482.             SEE ALSO
  9483.  
  9484.             RES320, RES640L, RES800, RES1024, RES1280, WHICHVGA
  9485.  
  9486.             EXAMPLE
  9487.  
  9488.             /*
  9489.              * set video mode to 640x480x256
  9490.              */
  9491.  
  9492.             #include <stdlib.h>
  9493.             #include <conio.h>
  9494.             #include "svgacc.h"
  9495.  
  9496.             void main(void)
  9497.             {
  9498.                int vmode;
  9499.  
  9500.                vmode = videomodeget();
  9501.                if ( !whichvga() )
  9502.                  exit(1);
  9503.                if ( whichmem() < 512 )
  9504.                  exit(1);
  9505.                res640();
  9506.                drwstring(1,7,0,"this is the 640x480x256 video
  9507.             mode...",0,0);
  9508.                getch();
  9509.                videomodeset(vmode);
  9510.                exit(0);
  9511.             }
  9512.  
  9513.  
  9514.  
  9515.                                                                         152
  9516.  
  9517.  
  9518.  
  9519.  
  9520.  
  9521.           RES640L
  9522.  
  9523.             PROTOTYPE
  9524.  
  9525.             extern int far res640l (void)
  9526.  
  9527.             INPUT
  9528.  
  9529.             no input parameters
  9530.  
  9531.             OUTPUT
  9532.  
  9533.             RES640L returns 1 if successful, 0 otherwise.
  9534.  
  9535.             USAGE
  9536.  
  9537.             RES640L sets the video mode to 640x400 graphics mode with 256
  9538.             colors.  This function requires that a Super VGA card with at
  9539.             least 256K of video memory be present.  Also, WHICHVGA must be
  9540.             called first or the function will fail without changing the
  9541.             video mode.  If the video card does not have sufficient
  9542.             memory, RES640L will return without changing the video mode.
  9543.  
  9544.             Note: The 640x400 is an uncommon resolution.  Many SVGA cards
  9545.             do not support this mode.
  9546.  
  9547.             SEE ALSO
  9548.  
  9549.             RES320, RES640, RES800, RES1024, RES1280, WHICHVGA
  9550.  
  9551.             EXAMPLE
  9552.  
  9553.             /*
  9554.              * set video mode to 640x400x256
  9555.              */
  9556.  
  9557.             #include <stdlib.h>
  9558.             #include <conio.h>
  9559.             #include "svgacc.h"
  9560.  
  9561.             void main(void)
  9562.             {
  9563.                int vmode;
  9564.  
  9565.                vmode = videomodeget();
  9566.                if ( !whichvga() )
  9567.                  exit(1);
  9568.                res640l();
  9569.                drwstring(1,7,0,"this is the 640x400x256 video
  9570.             mode...",0,0);
  9571.                getch();
  9572.                videomodeset(vmode);
  9573.                exit(0);
  9574.             }
  9575.  
  9576.  
  9577.                                                                         153
  9578.  
  9579.  
  9580.  
  9581.  
  9582.  
  9583.           RES800
  9584.  
  9585.             PROTOTYPE
  9586.  
  9587.             extern int far res800 (void)
  9588.  
  9589.             INPUT
  9590.  
  9591.             no input parameters
  9592.  
  9593.             OUTPUT
  9594.  
  9595.             RES800 returns 1 if successful, 0 otherwise.
  9596.  
  9597.             USAGE
  9598.  
  9599.             RES800 sets the video mode to 800x600 graphics mode with 256
  9600.             colors.  This function requires that a Super VGA card with at
  9601.             least 512K of video memory be present.  Also, WHICHVGA must be
  9602.             called first or the function will fail without changing the
  9603.             video mode.  If the video card does not have sufficient
  9604.             memory, RES800 will return without changing the video mode.
  9605.  
  9606.             SEE ALSO
  9607.  
  9608.             RES320, RES640, RES640L, RES1024, RES1280, WHICHVGA
  9609.  
  9610.             EXAMPLE
  9611.  
  9612.             /*
  9613.              * set video mode to 800x600x256
  9614.              */
  9615.  
  9616.             #include <stdlib.h>
  9617.             #include <conio.h>
  9618.             #include "svgacc.h"
  9619.  
  9620.             void main(void)
  9621.             {
  9622.                int vmode;
  9623.  
  9624.                vmode = videomodeget();
  9625.                if ( !whichvga() )
  9626.                  exit(1);
  9627.                if ( whichmem() < 512 )
  9628.                  exit(1);
  9629.                res800();
  9630.                drwstring(1,7,0,"this is the 800x600x256 video
  9631.             mode...",0,0);
  9632.                getch();
  9633.                videomodeset(vmode);
  9634.                exit(0);
  9635.             }
  9636.  
  9637.  
  9638.  
  9639.                                                                         154
  9640.  
  9641.  
  9642.  
  9643.  
  9644.  
  9645.           RES1024
  9646.  
  9647.             PROTOTYPE
  9648.  
  9649.             extern int far res1024 (void)
  9650.  
  9651.             INPUT
  9652.  
  9653.             no input parameters
  9654.  
  9655.             OUTPUT
  9656.  
  9657.             RES1024 returns 1 if successful, 0 otherwise.
  9658.  
  9659.             USAGE
  9660.  
  9661.             RES1024 sets the video mode to 1024x768 graphics mode with 256
  9662.             colors.  This function requires that a Super VGA card with at
  9663.             least 1 Megabyte of video memory be present.  Also, WHICHVGA
  9664.             must be called first or the function will fail without
  9665.             changing the video mode.  If the video card does not have
  9666.             sufficient memory, RES1024 will return without changing the
  9667.             video mode.
  9668.  
  9669.             SEE ALSO
  9670.  
  9671.             RES320, RES640, RES640L, RES800, RES1280, WHICHVGA
  9672.  
  9673.             EXAMPLE
  9674.  
  9675.             /*
  9676.              * set video mode to 1024x768x256
  9677.              */
  9678.  
  9679.             #include <stdlib.h>
  9680.             #include <conio.h>
  9681.             #include "svgacc.h"
  9682.  
  9683.             void main(void)
  9684.             {
  9685.                int vmode;
  9686.  
  9687.                vmode = videomodeget();
  9688.                if ( !whichvga() )
  9689.                  exit(1);
  9690.                if ( whichmem() < 1024 )
  9691.                  exit(1);
  9692.                res1024();
  9693.                drwstring(1,7,0,"this is the 1024x768x256 video
  9694.             mode...",0,0);
  9695.                getch();
  9696.                videomodeset(vmode);
  9697.                exit(0);
  9698.             }
  9699.  
  9700.  
  9701.                                                                         155
  9702.  
  9703.  
  9704.  
  9705.  
  9706.  
  9707.           RES1280
  9708.  
  9709.             PROTOTYPE
  9710.  
  9711.             extern int far res1280 (void)
  9712.  
  9713.             INPUT
  9714.  
  9715.             no input parameters
  9716.  
  9717.             OUTPUT
  9718.  
  9719.             RES1280 returns 1 if successful, 0 otherwise.
  9720.  
  9721.             USAGE
  9722.  
  9723.             RES1280 sets the video mode to 1280x1024 graphics mode with
  9724.             256 colors.  This function requires that a Super VGA card with
  9725.             at least 2 Megabytes of video memory be present.  Also,
  9726.             WHICHVGA must be called first or the function will fail
  9727.             without changing the video mode.  If the video card does not
  9728.             have sufficient memory, RES1280 will return without changing
  9729.             the video mode.
  9730.  
  9731.             SEE ALSO
  9732.  
  9733.             RES320, RES640, RES640L, RES800, RES1024, WHICHVGA
  9734.  
  9735.             EXAMPLE
  9736.  
  9737.             /*
  9738.              * set video mode to 1280x1024x256
  9739.              */
  9740.  
  9741.             #include <stdlib.h>
  9742.             #include <conio.h>
  9743.             #include "svgacc.h"
  9744.  
  9745.             void main(void)
  9746.             {
  9747.                int vmode;
  9748.  
  9749.                vmode = videomodeget();
  9750.                if ( !whichvga() )
  9751.                  exit(1);
  9752.                if ( whichmem() < 2048 )
  9753.                  exit(1);
  9754.                res1024();
  9755.                drwstring(1,7,0,"this is the 1280x1024x256 video
  9756.             mode...",0,0);
  9757.                getch();
  9758.                videomodeset(vmode);
  9759.                exit(0);
  9760.             }
  9761.  
  9762.  
  9763.                                                                         156
  9764.  
  9765.  
  9766.  
  9767.  
  9768.  
  9769.           RESTEXT
  9770.  
  9771.             PROTOTYPE
  9772.  
  9773.             extern int far restext (void)
  9774.  
  9775.             INPUT
  9776.  
  9777.             no input parameters
  9778.  
  9779.             OUTPUT
  9780.  
  9781.             RESTEXT always returns a 1.
  9782.  
  9783.             USAGE
  9784.  
  9785.             RESTEXT sets video mode three which is the industry standard
  9786.             80x25 text mode.
  9787.  
  9788.             SEE ALSO
  9789.  
  9790.             VIDEOMODEGET, VIDEOMODESET
  9791.  
  9792.             EXAMPLE
  9793.  
  9794.             /*
  9795.              * set video mode to standard DOS text mode 3
  9796.              */
  9797.  
  9798.             #include <stdlib.h>
  9799.             #include <conio.h>
  9800.             #include "svgacc.h"
  9801.  
  9802.             void main(void)
  9803.             {
  9804.                int vmode;
  9805.  
  9806.                vmode = videomodeget();
  9807.                if ( !restext() )
  9808.                  exit(1);
  9809.                printf("this is the text video mode (DOS video mode 3)...");
  9810.                getch();
  9811.                videomodeset(vmode);
  9812.                exit(0);
  9813.             }
  9814.  
  9815.  
  9816.  
  9817.  
  9818.  
  9819.  
  9820.  
  9821.  
  9822.  
  9823.  
  9824.  
  9825.                                                                         157
  9826.  
  9827.  
  9828.  
  9829.  
  9830.  
  9831.           SCROLLDN
  9832.  
  9833.             PROTOTYPE
  9834.  
  9835.             extern void far scrolldn (int x1, int y1, int x2, int y2, int
  9836.             num, int colr)
  9837.  
  9838.             INPUT
  9839.  
  9840.             x1, y1 - top left corner of block
  9841.             x2, y2 - bottom right corner of block
  9842.             num - number of pixels to shift
  9843.             colr - index to color in current palette
  9844.  
  9845.             OUTPUT
  9846.  
  9847.             no value returned
  9848.  
  9849.             USAGE
  9850.  
  9851.             SCROLLDN shifts the contents of the box described by (x1, y1)
  9852.             - (x2, y2) down by the number of pixels specified by num.  The
  9853.             empty pixels created at the top of the box are filled with
  9854.             colr.  The pixels that are shifted out of the box are lost.
  9855.             SCROLLDN enforces x2 x1 and y2y1.  When placed within a loop,
  9856.             SCROLLDN will create a scrolling effect.
  9857.  
  9858.             SEE ALSO
  9859.  
  9860.             SCROLLLT, SCROLLRT, SCROLLUP
  9861.  
  9862.             EXAMPLE
  9863.  
  9864.             /*
  9865.              * scroll some text down
  9866.              */
  9867.  
  9868.             #include <stdlib.h>
  9869.             #include <conio.h>
  9870.             #include "svgacc.h"
  9871.  
  9872.             void main(void)
  9873.             {
  9874.                int vmode, i;
  9875.  
  9876.                vmode = videomodeget();
  9877.                if ( !whichvga() || (whichmem() < 512))
  9878.                  exit(1);
  9879.                res640();
  9880.                drwbox (1,10,0,0,100,100);
  9881.                drwstring(1,7,0,"text text",20,43);
  9882.                for(i=0;i<40;i++)
  9883.                {
  9884.                  scrolldn(1,1,99,99,1,0);
  9885.  
  9886.  
  9887.                                                                         158
  9888.  
  9889.  
  9890.  
  9891.  
  9892.  
  9893.                  sdelay(2);
  9894.                }
  9895.                getch();
  9896.                videomodeset(vmode);
  9897.             }
  9898.  
  9899.  
  9900.  
  9901.  
  9902.  
  9903.  
  9904.  
  9905.  
  9906.  
  9907.  
  9908.  
  9909.  
  9910.  
  9911.  
  9912.  
  9913.  
  9914.  
  9915.  
  9916.  
  9917.  
  9918.  
  9919.  
  9920.  
  9921.  
  9922.  
  9923.  
  9924.  
  9925.  
  9926.  
  9927.  
  9928.  
  9929.  
  9930.  
  9931.  
  9932.  
  9933.  
  9934.  
  9935.  
  9936.  
  9937.  
  9938.  
  9939.  
  9940.  
  9941.  
  9942.  
  9943.  
  9944.  
  9945.  
  9946.  
  9947.  
  9948.  
  9949.                                                                         159
  9950.  
  9951.  
  9952.  
  9953.  
  9954.  
  9955.           SCROLLLT
  9956.  
  9957.             PROTOTYPE
  9958.  
  9959.             extern void far scrolllt (int x1, int y1, int x2, int y2, int
  9960.             num, int colr)
  9961.  
  9962.             INPUT
  9963.  
  9964.             x1, y1 - top left corner of block
  9965.             x2, y2 - bottom right corner of block
  9966.             num - number of pixels to shift
  9967.             colr - index to color in current palette
  9968.  
  9969.             OUTPUT
  9970.  
  9971.             no value returned
  9972.  
  9973.             USAGE
  9974.  
  9975.             SCROLLLT shifts the contents of the box described by (x1, y1)
  9976.             - (x2, y2) down by the number of pixels specified by num.  The
  9977.             empty pixels created at the right of the box are filled with
  9978.             colr.  The pixels that are shifted out of the box are lost.
  9979.             SCROLLLT enforces x2 x1 and y2y1.  When placed within a loop,
  9980.             SCROLLRT will create a scrolling effect.
  9981.  
  9982.             SEE ALSO
  9983.  
  9984.             SCROLLDN, SCROLLRT, SCROLLUP
  9985.  
  9986.             EXAMPLE
  9987.  
  9988.             /*
  9989.              * scroll some text left
  9990.              */
  9991.  
  9992.             #include <stdlib.h>
  9993.             #include <conio.h>
  9994.             #include "svgacc.h"
  9995.  
  9996.             void main(void)
  9997.             {
  9998.                int vmode, i;
  9999.  
  10000.                vmode = videomodeget();
  10001.                if ( !whichvga() || (whichmem() < 512))
  10002.                  exit(1);
  10003.                res640();
  10004.                drwbox (1,10,0,0,100,100);
  10005.                drwstring(1,7,0,"text text",20,43);
  10006.                for(i=0;i<40;i++)
  10007.                {
  10008.                  scrolllt(1,1,99,99,1,0);
  10009.  
  10010.  
  10011.                                                                         160
  10012.  
  10013.  
  10014.  
  10015.  
  10016.  
  10017.                  sdelay(2);
  10018.                }
  10019.                getch();
  10020.                videomodeset(vmode);
  10021.             }
  10022.  
  10023.  
  10024.  
  10025.  
  10026.  
  10027.  
  10028.  
  10029.  
  10030.  
  10031.  
  10032.  
  10033.  
  10034.  
  10035.  
  10036.  
  10037.  
  10038.  
  10039.  
  10040.  
  10041.  
  10042.  
  10043.  
  10044.  
  10045.  
  10046.  
  10047.  
  10048.  
  10049.  
  10050.  
  10051.  
  10052.  
  10053.  
  10054.  
  10055.  
  10056.  
  10057.  
  10058.  
  10059.  
  10060.  
  10061.  
  10062.  
  10063.  
  10064.  
  10065.  
  10066.  
  10067.  
  10068.  
  10069.  
  10070.  
  10071.  
  10072.  
  10073.                                                                         161
  10074.  
  10075.  
  10076.  
  10077.  
  10078.  
  10079.           SCROLLRT
  10080.  
  10081.             PROTOTYPE
  10082.  
  10083.             extern void far scrollrt (int x1, int y1, int x2, int y2, int
  10084.             num, int colr)
  10085.  
  10086.             INPUT
  10087.  
  10088.             x1, y1 - top left corner of block
  10089.             x2, y2 - bottom right corner of block
  10090.             num - number of pixels to shift
  10091.             colr - index to color in current palette
  10092.  
  10093.             OUTPUT
  10094.  
  10095.             no value returned
  10096.  
  10097.             USAGE
  10098.  
  10099.             SCROLLRT shifts the contents of the box described by (x1, y1)
  10100.             - (x2, y2) down by the number of pixels specified by num.  The
  10101.             empty pixels created at the left of the box are filled with
  10102.             colr.  The pixels that are shifted out of the box are lost.
  10103.             SCROLLRT enforces x2 x1 and y2y1.  When placed within a loop,
  10104.             SCROLLRT will create a scrolling effect.
  10105.  
  10106.             SEE ALSO
  10107.  
  10108.             SCROLLDN, SCROLLLT, SCROLLUP
  10109.  
  10110.             EXAMPLE
  10111.  
  10112.             /*
  10113.              * scroll some text right
  10114.              */
  10115.  
  10116.             #include <stdlib.h>
  10117.             #include <conio.h>
  10118.             #include "svgacc.h"
  10119.  
  10120.             void main(void)
  10121.             {
  10122.                int vmode, i;
  10123.  
  10124.                vmode = videomodeget();
  10125.                if ( !whichvga() || (whichmem() < 512))
  10126.                  exit(1);
  10127.                res640();
  10128.                drwbox (1,10,0,0,100,100);
  10129.                drwstring(1,7,0,"text text",20,43);
  10130.                for(i=0;i<40;i++)
  10131.                {
  10132.                  scrollrt(1,1,99,99,1,0);
  10133.  
  10134.  
  10135.                                                                         162
  10136.  
  10137.  
  10138.  
  10139.  
  10140.  
  10141.                  sdelay(2);
  10142.                }
  10143.                getch();
  10144.                videomodeset(vmode);
  10145.             }
  10146.  
  10147.  
  10148.  
  10149.  
  10150.  
  10151.  
  10152.  
  10153.  
  10154.  
  10155.  
  10156.  
  10157.  
  10158.  
  10159.  
  10160.  
  10161.  
  10162.  
  10163.  
  10164.  
  10165.  
  10166.  
  10167.  
  10168.  
  10169.  
  10170.  
  10171.  
  10172.  
  10173.  
  10174.  
  10175.  
  10176.  
  10177.  
  10178.  
  10179.  
  10180.  
  10181.  
  10182.  
  10183.  
  10184.  
  10185.  
  10186.  
  10187.  
  10188.  
  10189.  
  10190.  
  10191.  
  10192.  
  10193.  
  10194.  
  10195.  
  10196.  
  10197.                                                                         163
  10198.  
  10199.  
  10200.  
  10201.  
  10202.  
  10203.           SCROLLUP
  10204.  
  10205.             PROTOTYPE
  10206.  
  10207.             extern void far scrollup (int x1, int y1, int x2, int y2, int
  10208.             num, int colr)
  10209.  
  10210.             INPUT
  10211.  
  10212.             x1, y1 - top left corner of block
  10213.             x2, y2 - bottom right corner of block
  10214.             num - number of pixels to shift
  10215.             colr - index to color in current palette
  10216.  
  10217.             OUTPUT
  10218.  
  10219.             no value returned
  10220.  
  10221.             USAGE
  10222.  
  10223.             SCROLLUP shifts the contents of the box described by (x1, y1)
  10224.             - (x2, y2) down by the number of pixels specified by num.  The
  10225.             empty pixels created at the bottom of the box are filled with
  10226.             colr.  The pixels that are shifted out of the box are lost.
  10227.             SCROLLUP enforces x2 x1 and y2y1.  When placed within a loop,
  10228.             SCROLLUP will create a scrolling effect.
  10229.  
  10230.             SEE ALSO
  10231.  
  10232.             SCROLLDN, SCROLLLT, SCROLLRT
  10233.  
  10234.             EXAMPLE
  10235.  
  10236.             /*
  10237.              * scroll some text up
  10238.              */
  10239.  
  10240.             #include <stdlib.h>
  10241.             #include <conio.h>
  10242.             #include "svgacc.h"
  10243.  
  10244.             void main(void)
  10245.             {
  10246.                int vmode, i;
  10247.  
  10248.                vmode = videomodeget();
  10249.                if ( !whichvga() || (whichmem() < 512))
  10250.                  exit(1);
  10251.                res640();
  10252.                drwbox (1,10,0,0,100,100);
  10253.                drwstring(1,7,0,"text text",20,43);
  10254.                for(i=0;i<40;i++)
  10255.                {
  10256.                  scrollup(1,1,99,99,1,0);
  10257.  
  10258.  
  10259.                                                                         164
  10260.  
  10261.  
  10262.  
  10263.  
  10264.  
  10265.                  sdelay(2);
  10266.                }
  10267.                getch();
  10268.                videomodeset(vmode);
  10269.             }
  10270.  
  10271.  
  10272.  
  10273.  
  10274.  
  10275.  
  10276.  
  10277.  
  10278.  
  10279.  
  10280.  
  10281.  
  10282.  
  10283.  
  10284.  
  10285.  
  10286.  
  10287.  
  10288.  
  10289.  
  10290.  
  10291.  
  10292.  
  10293.  
  10294.  
  10295.  
  10296.  
  10297.  
  10298.  
  10299.  
  10300.  
  10301.  
  10302.  
  10303.  
  10304.  
  10305.  
  10306.  
  10307.  
  10308.  
  10309.  
  10310.  
  10311.  
  10312.  
  10313.  
  10314.  
  10315.  
  10316.  
  10317.  
  10318.  
  10319.  
  10320.  
  10321.                                                                         165
  10322.  
  10323.  
  10324.  
  10325.  
  10326.  
  10327.           SDELAY
  10328.  
  10329.             PROTOTYPE
  10330.  
  10331.             extern void far sdelay (int count)
  10332.  
  10333.             INPUT
  10334.  
  10335.             count - number of vertical syncs to wait
  10336.  
  10337.             OUTPUT
  10338.  
  10339.             no value returned
  10340.  
  10341.             USAGE
  10342.  
  10343.             SDELAY pauses execution of the program for a period of time
  10344.             specified by count.  This delay remains approximately constant
  10345.             on all machines by using the vertical sync timer of the VGA
  10346.             graphics card which is about 60 - 70 Hz.
  10347.  
  10348.             EXAMPLE
  10349.  
  10350.             /*
  10351.              * make a delay of about 3 seconds long
  10352.              */
  10353.  
  10354.             #include <stdlib.h>
  10355.             #include <conio.h>
  10356.             #include <time.h>
  10357.             #include "svgacc.h"
  10358.  
  10359.             void main(void)
  10360.             {
  10361.                time_t starttime;
  10362.                time_t endtime;
  10363.                printf("ok...stating delay...should be about 3 seconds...");
  10364.                time( &starttime);
  10365.                sdelay(195);
  10366.                time( &endtime);
  10367.                printf("total time was: %d seconds...", endtime-starttime);
  10368.                exit(0);
  10369.             }
  10370.  
  10371.  
  10372.  
  10373.  
  10374.  
  10375.  
  10376.  
  10377.  
  10378.  
  10379.  
  10380.  
  10381.  
  10382.  
  10383.                                                                         166
  10384.  
  10385.  
  10386.  
  10387.  
  10388.  
  10389.           SETCARD
  10390.  
  10391.             PROTOTYPE
  10392.  
  10393.             extern void far setcard (VGAChipset chip, int mem)
  10394.  
  10395.             INPUT
  10396.  
  10397.             chip - code for SVGA chip type
  10398.             mem - amount of video memory installed
  10399.  
  10400.             OUTPUT
  10401.  
  10402.             no value returned
  10403.  
  10404.             USAGE
  10405.  
  10406.             WARNING:  USING SETCARD IMPROPERLY MAY CAUSE A SYSTEM FAILURE
  10407.             OR DAMAGE.
  10408.             SETCARD sets the card type and installed video memory.  It can
  10409.             be used instead of the WHICHVGA function.  However, specifying
  10410.             an incorrect chip type or installed video memory may cause
  10411.             unpredictable results not excluding damage to the SVGA card
  10412.             and/or monitor.  Extreme caution is advised when using this
  10413.             function.  It is recommended that this function only be used
  10414.             when it is suspected that the identification process in
  10415.             WHICHVGA failed.  Be absolutely certain that the chip type
  10416.             specified is the actual chip type installed in the computer.
  10417.             Mem should be a value of 256, 512 or 1024 representing the
  10418.             kilobytes of video memory installed.  Use the following table
  10419.             to identify chip types:
  10420.  
  10421.           1  Acumos AVGA2/3 SuperVGA
  10422.           2  ATI Technologies 18/28/38/68800
  10423.              SuperVGA
  10424.           3  Ahead V5000 ver A SuperVGA
  10425.           4  Ahead V5000 ver B SuperVGA
  10426.           5  Chips and Technologies 82C45x SuperVGA
  10427.           6  Cirrus Logic CL-GD 5xx, 6xx, 28xx,
  10428.              54xx, 62xx SuperVGA
  10429.           7  Everex Micro Enhancer Ev236/6xx
  10430.              SuperVGA
  10431.           8  Genoa 61/62/63/64/6600 SuperVGA
  10432.           9  NCR 77C21/22/22E/22E+ SuperVGA
  10433.           10 Oak Technologies OTI-037C/067/077/087
  10434.              SuperVGA
  10435.           11 Paradise/Western Digital PVGA1A,
  10436.              WD90C00/1x/2x/3x SuperVGA
  10437.           12 Realtek RT3106 SuperVGA
  10438.           13 Trident 8800CS, 8900B/C/CL/CX, 90x0
  10439.              SuperVGA
  10440.           14 Tseng Labs ET3000-AX/BX/BP SuperVGA
  10441.           15 Tseng Labs ET4000/W32/W32I SuperVGA
  10442.           16 VESA compatible SuperVGA
  10443.  
  10444.  
  10445.                                                                         167
  10446.  
  10447.  
  10448.  
  10449.  
  10450.  
  10451.           17 Video 7 HT-208/16 SuperVGA
  10452.           18 Avance Logic AL2101 SuperVGA
  10453.           19 MXIC MX68000/10 SuperVGA
  10454.           20 Primus P2000 SuperVGA
  10455.  
  10456.             SEE ALSO
  10457.  
  10458.             WHICHVGA
  10459.  
  10460.             EXAMPLE
  10461.  
  10462.             /*
  10463.             !WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNI
  10464.             NG!  */
  10465.             /*                                                        */
  10466.             /* USE THE "SETCARD" FUNCTION CAREFULLY. IT WORKS AROUND
  10467.             "WHICHVGA".  */
  10468.             /* IMPROPER USE (I.E. SETTING THE CARD ID AND MEMORY TO
  10469.             SOMETHING    */
  10470.             /* THAT IS NOT VALID) MIGHT DAMAGE YOUR VIDEO CARD/VIDEO
  10471.             MONITOR OR   */
  10472.             /* CAUSE UNPREDICTABLE RESULTS. IT IS PROVIDED AS A METHOD TO
  10473.             FIND */
  10474.             /* FAULTS IN THE VIDEO CARD/CHIP ID PROCESS.
  10475.                */
  10476.             /*                                                        */
  10477.             /*
  10478.             !WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNING!WARNI
  10479.             NG!  */
  10480.  
  10481.  
  10482.  
  10483.  
  10484.  
  10485.  
  10486.  
  10487.  
  10488.  
  10489.  
  10490.  
  10491.  
  10492.  
  10493.  
  10494.  
  10495.  
  10496.  
  10497.  
  10498.  
  10499.  
  10500.  
  10501.  
  10502.  
  10503.  
  10504.  
  10505.  
  10506.  
  10507.                                                                         168
  10508.  
  10509.  
  10510.  
  10511.  
  10512.  
  10513.           SETVIEW
  10514.  
  10515.             PROTOTYPE
  10516.  
  10517.             extern void far setview (int x1, int y1, int x2, int y2)
  10518.  
  10519.             INPUT
  10520.  
  10521.             x1, y1 - top, left corner of view port
  10522.             x2, y2 - bottom, right corner of view port
  10523.  
  10524.             OUTPUT
  10525.  
  10526.             no value returned
  10527.  
  10528.             USAGE
  10529.  
  10530.             SETVIEW defines a viewport for clipping output on the screen.
  10531.             Nothing can be drawn outside of the currently defined
  10532.             viewport.  The RES### functions set the viewport to the full
  10533.             screen.  The restrictions on X1, Y1, X2 and Y2 are as follows:
  10534.  
  10535.             0   X1 < X2  (screen width)
  10536.             0   Y1 < Y2  (32767, effectively unbounded)
  10537.  
  10538.             SEE ALSO
  10539.  
  10540.             RES320, RES640, RES640L, RES800, RES1024, RES1280
  10541.  
  10542.             EXAMPLE
  10543.  
  10544.             /*
  10545.              * draws a lines clipped to a view port
  10546.              */
  10547.  
  10548.             #include <stdlib.h>
  10549.             #include <conio.h>
  10550.             #include "svgacc.h"
  10551.             #define randnum(size) (rand() % (int)(size))
  10552.  
  10553.             void main(void)
  10554.             {
  10555.                int vmode, i, x1, y1, x2, y2;
  10556.  
  10557.                vmode = videomodeget();
  10558.                if ( !whichvga() || (whichmem() < 512))
  10559.                  exit(1);
  10560.                res640();
  10561.                drwbox(1,15,101,101,538,378);
  10562.                setview(101,101,538,378);
  10563.                for(i=0;i<300;i++) {
  10564.                  x1 = randnum(640);
  10565.                  y1 = randnum(480);
  10566.                  x2 = randnum(640);
  10567.  
  10568.  
  10569.                                                                         169
  10570.  
  10571.  
  10572.  
  10573.  
  10574.  
  10575.                  y2 = randnum(480);
  10576.                  drwline(1,10,x1,y1,x2,y2);
  10577.                }
  10578.                getch();
  10579.                videomodeset(vmode);
  10580.                exit(0);
  10581.             }
  10582.  
  10583.  
  10584.  
  10585.  
  10586.  
  10587.  
  10588.  
  10589.  
  10590.  
  10591.  
  10592.  
  10593.  
  10594.  
  10595.  
  10596.  
  10597.  
  10598.  
  10599.  
  10600.  
  10601.  
  10602.  
  10603.  
  10604.  
  10605.  
  10606.  
  10607.  
  10608.  
  10609.  
  10610.  
  10611.  
  10612.  
  10613.  
  10614.  
  10615.  
  10616.  
  10617.  
  10618.  
  10619.  
  10620.  
  10621.  
  10622.  
  10623.  
  10624.  
  10625.  
  10626.  
  10627.  
  10628.  
  10629.  
  10630.  
  10631.                                                                         170
  10632.  
  10633.  
  10634.  
  10635.  
  10636.  
  10637.           SPRITECOLLDETECT
  10638.  
  10639.             PROTOTYPE
  10640.  
  10641.             extern int far spritecolldetect (int transcolr, int x1, int
  10642.             y1, int x2, int y2, RasterBlock far *sprite1, RasterBlock far
  10643.             *sprite2)
  10644.  
  10645.             INPUT
  10646.  
  10647.             transcolr - index to color in current palette
  10648.             x1, y1 - location of top, left corner of sprite number 1
  10649.             x2, y2 - location of top, left corner of sprite number 2
  10650.             sprite1 - sprite number 1
  10651.             sprite2 - sprite number 2
  10652.  
  10653.             OUTPUT
  10654.  
  10655.             SPRITECOLLDETECT returns the collision status of the two
  10656.             sprites.
  10657.  
  10658.             USAGE
  10659.  
  10660.             SPRITECOLLDETECT is used in sprite graphics or animation to
  10661.             report the collision status between two sprites.  Sprite1
  10662.             contains the first sprite which should have been previously
  10663.             defined by BLKGET or similar function.  Sprite2, likewise,
  10664.             contains the second sprite.  The top, left corner of the first
  10665.             and second sprites' locations are specified by x1, y1 and x2,
  10666.             y2, respectively.
  10667.  
  10668.             SPRITECOLLDETECT will return a zero if the sprites are not
  10669.             colliding and the blocks are not overlapping.  The return will
  10670.             be one if the blocks overlap, but the sprites are not
  10671.             colliding.  A return value of two indicates that the sprites
  10672.             have at least one overlapping pixel and are, therefore,
  10673.             colliding.
  10674.  
  10675.             SEE ALSO
  10676.  
  10677.             BLKGET, BLKPUT, GETLASTSTRING, SPRITEGAP, SPRITEGET, SPRITEPUT
  10678.  
  10679.             EXAMPLE
  10680.  
  10681.             /*
  10682.              * shows how spritecolldetect works
  10683.              */
  10684.  
  10685.             #include <stdlib.h>
  10686.             #include <conio.h>
  10687.             #include "svgacc.h"
  10688.  
  10689.             void main(void)
  10690.             {
  10691.  
  10692.  
  10693.                                                                         171
  10694.  
  10695.  
  10696.  
  10697.  
  10698.  
  10699.                int vmode, ret, i, x1, y1, x2, y2;
  10700.                char text[70];
  10701.  
  10702.                RasterBlock *sprite1data, *sprite2data;
  10703.  
  10704.                vmode = videomodeget();
  10705.                if ( !whichvga() )
  10706.                  exit(1);
  10707.                res320();
  10708.                x1 = 0;
  10709.                y1 = 0;
  10710.                x2 = 48;
  10711.                y2 = 48;
  10712.                drwline(1,8,x1,y1,x2,y1);
  10713.                drwline(1,8,x2,y1,x2,y2);
  10714.                drwline(1,8,x2,y2,x1,y2);
  10715.                drwline(1,8,x1,y2,x1,y1);
  10716.                fillarea(x1+1,y1+1,8,8);
  10717.                drwellipse(1,10,((x2-x1)/2+x1),((y2-y1)/2+y1),(x2-x1)/2,(y2-
  10718.             y1)/2);
  10719.                sprite1data = (RasterBlock *)malloc((x2-x1+1)*(y2-y1+1)+4);
  10720.                blkget(x1,y1,x2,y2,sprite1data);
  10721.                blkput(2,x1,y1,sprite1data);
  10722.                x1 = 0;
  10723.                y1 = 0;
  10724.                x2 = 24;
  10725.                y2 = 24;
  10726.                drwline(1,8,x1,y1,x2,y1);
  10727.                drwline(1,8,x2,y1,x2,y2);
  10728.                drwline(1,8,x2,y2,x1,y2);
  10729.                drwline(1,8,x1,y2,x1,y1);
  10730.                fillarea(x1+1,y1+1,8,8);
  10731.                drwline(1,10,x1,y1,x2,y2);
  10732.                drwline(1,10,x2,y1,x1,y2);
  10733.                sprite2data = (RasterBlock *)malloc((x2-x1+1)*(y2-y1+1)+4);
  10734.                blkget(x1,y1,x2,y2,sprite2data);
  10735.                blkput(2,x1,y1,sprite2data);
  10736.                x1=90;
  10737.                y1=90;
  10738.                blkput(2,x1,y1,sprite1data);
  10739.                for(i=30;i<150;i++)
  10740.                {
  10741.                  blkput(2,i,i,sprite2data);
  10742.                  ret =
  10743.             spritecolldetect(8,x1,y1,i,i,sprite1data,sprite2data);
  10744.                  sprintf(text,"the return value is: %d",ret);
  10745.                  drwstring(1,7,0,text,0,0);
  10746.                  getch();
  10747.                  blkput(2,i,i,sprite2data);
  10748.                }
  10749.                videomodeset(vmode);
  10750.                exit(0);
  10751.             }
  10752.  
  10753.  
  10754.  
  10755.                                                                         172
  10756.  
  10757.  
  10758.  
  10759.  
  10760.  
  10761.           SPRITEGAP
  10762.  
  10763.             PROTOTYPE
  10764.  
  10765.             extern void far spritegap (int transcolr, int x, int y,
  10766.             RasterBlock far *sprite, RasterBlock far *spritebkgnd)
  10767.  
  10768.             INPUT
  10769.  
  10770.             transcolr - index to color in current palette
  10771.             x, y - top, left corner of block
  10772.             sprite- the sprite to place on screen
  10773.  
  10774.             OUTPUT
  10775.  
  10776.             no value returned
  10777.             spritebkgnd - sprite background
  10778.  
  10779.             USAGE
  10780.  
  10781.             SPRITEGAP ("Sprite-Get-And-Put") is used in sprite graphics or
  10782.             animation to retrieve a sprite's background and then display
  10783.             the sprite.  Sprite contains the sprite which should have been
  10784.             previously defined by BLKGET or similar function such as
  10785.             GETLASTSTRING.  Transcolr is the transparent colr assumed in
  10786.             sprite.  Spritebkgnd, a pointer to a RasterBlock structure the
  10787.             same size as the sprite, will receive the sprite's background.
  10788.             The top, left corner of the sprite's location is specified by
  10789.             x, y.
  10790.  
  10791.             SEE ALSO
  10792.  
  10793.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGET,
  10794.             SPRITEPUT
  10795.  
  10796.             EXAMPLE
  10797.  
  10798.             /*
  10799.              * Show spritegap
  10800.              */
  10801.  
  10802.             #include <stdlib.h>
  10803.             #include <math.h>
  10804.             #include <conio.h>
  10805.             #include "svgacc.h"
  10806.  
  10807.             void main(void)
  10808.             {
  10809.                int vmode;
  10810.                int i, j, colr, xinc, yinc, x1, y1, x2, y2, cnt, cntx, cnty,
  10811.             rot;
  10812.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  10813.  
  10814.                vmode = videomodeget();
  10815.  
  10816.  
  10817.                                                                         173
  10818.  
  10819.  
  10820.  
  10821.  
  10822.  
  10823.                if ( !whichvga() )
  10824.                  exit(1);
  10825.                if ( whichmem() < 512)
  10826.                  exit(1);
  10827.                if ( !res640() )
  10828.                  exit(1);
  10829.                xinc = maxx/20;
  10830.                yinc = maxy/20;
  10831.                x1 = maxx/2-xinc;
  10832.                y1 = maxy/2-yinc;
  10833.                x2 = maxx/2+xinc;
  10834.                y2 = maxy/2+yinc;
  10835.                i = (x2-x1+1)*(y2-y1+1)+4;
  10836.                gfxblk = (RasterBlock *)malloc(i);
  10837.                if (!gfxblk) {
  10838.                  restext();
  10839.                  printf("ERROR: Allocating memory for gfxblk: %d
  10840.             bytes\n",i);
  10841.                  exit(1);
  10842.                }
  10843.                colr = 1;
  10844.                for(i=0;i<=maxx/2;i++) {
  10845.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  10846.                  colr+=1;
  10847.                  if(colr>15)
  10848.                     colr = 1;
  10849.                }
  10850.                drwbox(1,0,x1,y1,x2,y2);
  10851.                blkget(x1,y1,x2,y2,gfxblk);
  10852.                cntx = (x2-x1) / 2 + x1;
  10853.                cnty = (y2-y1) / 2 + y1;
  10854.                fillarea(x1+2,y1+2,0,0);
  10855.                i = blkrotatesize(45,gfxblk);
  10856.                spritebkgnd = (RasterBlock *)malloc(i);
  10857.                if (!spritebkgnd) {
  10858.                  restext();
  10859.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  10860.             bytes\n",i);
  10861.                  exit(1);
  10862.                }
  10863.                gfxblk2 = (RasterBlock *)malloc(i);
  10864.                if (!gfxblk2) {
  10865.                  restext();
  10866.                  printf("ERROR: Allocating memory for gfxblk2: %d
  10867.             bytes\n",i);
  10868.                  exit(1);
  10869.                }
  10870.                blkget(x1,y1,x2,y2,spritebkgnd);
  10871.                setview(0,64,maxx,maxy);
  10872.                for(i=0;i<=360;i+=3) {
  10873.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  10874.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10875.             (spritebkgnd->height)/2,spritebkgnd);
  10876.  
  10877.  
  10878.  
  10879.                                                                         174
  10880.  
  10881.  
  10882.  
  10883.  
  10884.  
  10885.                  spritegap(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  10886.             >height)/2,gfxblk2,spritebkgnd);
  10887.                  sdelay(3);
  10888.                }
  10889.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  10890.             (spritebkgnd->height)/2,spritebkgnd);
  10891.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  10892.                getch();
  10893.                videomodeset(vmode);
  10894.                exit(0);
  10895.             }
  10896.  
  10897.  
  10898.  
  10899.  
  10900.  
  10901.  
  10902.  
  10903.  
  10904.  
  10905.  
  10906.  
  10907.  
  10908.  
  10909.  
  10910.  
  10911.  
  10912.  
  10913.  
  10914.  
  10915.  
  10916.  
  10917.  
  10918.  
  10919.  
  10920.  
  10921.  
  10922.  
  10923.  
  10924.  
  10925.  
  10926.  
  10927.  
  10928.  
  10929.  
  10930.  
  10931.  
  10932.  
  10933.  
  10934.  
  10935.  
  10936.  
  10937.  
  10938.  
  10939.  
  10940.  
  10941.                                                                         175
  10942.  
  10943.  
  10944.  
  10945.  
  10946.  
  10947.           SPRITEGET
  10948.  
  10949.             PROTOTYPE
  10950.  
  10951.             extern void far spriteget (int transcolr, int x, int y,
  10952.             RasterBlock far *sprite, RasterBlock far *spritebkgnd)
  10953.  
  10954.             INPUT
  10955.  
  10956.             transcolr - index to color in current palette
  10957.             x, y - top, left corner of block
  10958.             sprite - sprite to use as pattern
  10959.  
  10960.             OUTPUT
  10961.  
  10962.             no value returned
  10963.             spritebkgnd - sprite background
  10964.  
  10965.             USAGE
  10966.  
  10967.             SPRITEGET is used in sprite graphics or animation to retrieve
  10968.             the background for a sprite, normally just before using
  10969.             SPRITEPUT.  Sprite contains the sprite which should have been
  10970.             previously defined by BLKGET or similar function.  Transcolr
  10971.             is the transparent color assumed in the sprite.  Spritebkgnd,
  10972.             a pointer to a RasterBlock structure the same size as the
  10973.             sprite, will receive the sprite's background.  The top, left
  10974.             corner of the sprite's location is specified by x, y.
  10975.  
  10976.             SEE ALSO
  10977.  
  10978.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGAP,
  10979.             SPRITEPUT
  10980.  
  10981.             EXAMPLE
  10982.  
  10983.             /*
  10984.              * Show spriteget
  10985.              */
  10986.  
  10987.             #include <stdlib.h>
  10988.             #include <math.h>
  10989.             #include <conio.h>
  10990.             #include "svgacc.h"
  10991.  
  10992.             void main(void)
  10993.             {
  10994.                int vmode, i, j, colr, xinc, yinc, x1, y1, x2, y2, cntx,
  10995.             cnty, rot;
  10996.                RasterBlock *gfxblk, *gfxblk2, *spritebkgnd;
  10997.                vmode = videomodeget();
  10998.                if ( !whichvga() )
  10999.                  exit(1);
  11000.                if ( whichmem() < 512)
  11001.  
  11002.  
  11003.                                                                         176
  11004.  
  11005.  
  11006.  
  11007.  
  11008.  
  11009.                  exit(1);
  11010.                if ( !res640() )
  11011.                  exit(1);
  11012.                xinc = maxx/20;
  11013.                yinc = maxy/20;
  11014.                x1 = maxx/2-xinc;
  11015.                y1 = maxy/2-yinc;
  11016.                x2 = maxx/2+xinc;
  11017.                y2 = maxy/2+yinc;
  11018.                i = (x2-x1+1)*(y2-y1+1)+4;
  11019.                gfxblk = (RasterBlock *)malloc(i);
  11020.                if (!gfxblk) {
  11021.                  restext();
  11022.                  printf("ERROR: Allocating memory for gfxblk: %d
  11023.             bytes\n",i);
  11024.                  exit(1);
  11025.                }
  11026.                colr = 1;
  11027.                for(i=0;i<=maxx/2;i++) {
  11028.                  drwcircle(1,colr,maxx/4+i,maxy/2,maxy/5);
  11029.                  colr+=1;
  11030.                  if(colr>15)
  11031.                     colr = 1;
  11032.                }
  11033.                drwbox(1,0,x1,y1,x2,y2);
  11034.                blkget(x1,y1,x2,y2,gfxblk);
  11035.                cntx = (x2-x1) / 2 + x1;
  11036.                cnty = (y2-y1) / 2 + y1;
  11037.                fillarea(x1+2,y1+2,0,0);
  11038.                i = blkrotatesize(45,gfxblk);
  11039.                spritebkgnd = (RasterBlock *)malloc(i);
  11040.                if (!spritebkgnd) {
  11041.                  restext();
  11042.                  printf("ERROR: Allocating memory for spritebkgnd: %d
  11043.             bytes\n",i);
  11044.                  exit(1);
  11045.                }
  11046.                gfxblk2 = (RasterBlock *)malloc(i);
  11047.                if (!gfxblk2) {
  11048.                  restext();
  11049.                  printf("ERROR: Allocating memory for gfxblk2: %d
  11050.             bytes\n",i);
  11051.                  exit(1);
  11052.                }
  11053.                blkget(x1,y1,x2,y2,spritebkgnd);
  11054.                setview(0,64,maxx,maxy);
  11055.                for(i=0;i<=360;i+=3) {
  11056.                  rot = blkrotate(i,1,gfxblk,gfxblk2);
  11057.                  spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  11058.             (spritebkgnd->height)/2,spritebkgnd);
  11059.                  spriteget(1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  11060.             >height)/2,gfxblk2,spritebkgnd);
  11061.                  spriteput(SET,1,cntx-(gfxblk2->width)/2,cnty-(gfxblk2-
  11062.             >height)/2,gfxblk2);
  11063.  
  11064.  
  11065.                                                                         177
  11066.  
  11067.  
  11068.  
  11069.  
  11070.  
  11071.                  sdelay(3);
  11072.                }
  11073.                spriteput(SET,1,cntx-(spritebkgnd->width)/2,cnty-
  11074.             (spritebkgnd->height)/2,spritebkgnd);
  11075.                blkput(SET,x1,y1,(RasterBlock *)gfxblk);
  11076.                getch();
  11077.                videomodeset(vmode);
  11078.                exit(0);
  11079.             }
  11080.  
  11081.  
  11082.  
  11083.  
  11084.  
  11085.  
  11086.  
  11087.  
  11088.  
  11089.  
  11090.  
  11091.  
  11092.  
  11093.  
  11094.  
  11095.  
  11096.  
  11097.  
  11098.  
  11099.  
  11100.  
  11101.  
  11102.  
  11103.  
  11104.  
  11105.  
  11106.  
  11107.  
  11108.  
  11109.  
  11110.  
  11111.  
  11112.  
  11113.  
  11114.  
  11115.  
  11116.  
  11117.  
  11118.  
  11119.  
  11120.  
  11121.  
  11122.  
  11123.  
  11124.  
  11125.  
  11126.  
  11127.                                                                         178
  11128.  
  11129.  
  11130.  
  11131.  
  11132.  
  11133.           SPRITEPUT
  11134.  
  11135.             PROTOTYPE
  11136.  
  11137.             extern void far spriteput (PixelMode mode, int transcolr, int
  11138.             x, int y, RasterBlock far *sprite)
  11139.  
  11140.             INPUT
  11141.  
  11142.             mode - pixel write mode
  11143.             transcolr - index to color in current palette
  11144.             x, y - top, left corner of block
  11145.             sprite- sprite to place on screen
  11146.  
  11147.             OUTPUT
  11148.  
  11149.             no value returned
  11150.  
  11151.             USAGE
  11152.  
  11153.             SPRITEPUT is used in sprite graphics or animation to display a
  11154.             sprite or, more commonly, its background.  Sprite contains the
  11155.             sprite which should have been previously defined by BLKGET,
  11156.             SPRITEGAP or SPRITEGET.  Transcolr is the transparent color
  11157.             assumed in sprite.  The top, left corner of the sprite's
  11158.             location is specified by x, y.
  11159.  
  11160.             SEE ALSO
  11161.  
  11162.             BLKGET, BLKPUT, GETLASTSTRING, SPRITECOLLDETECT, SPRITEGAP,
  11163.             SPRITEGET
  11164.  
  11165.             EXAMPLE
  11166.  
  11167.             See SPRITEGET
  11168.  
  11169.  
  11170.  
  11171.  
  11172.  
  11173.  
  11174.  
  11175.  
  11176.  
  11177.  
  11178.  
  11179.  
  11180.  
  11181.  
  11182.  
  11183.  
  11184.  
  11185.  
  11186.  
  11187.  
  11188.  
  11189.                                                                         179
  11190.  
  11191.  
  11192.  
  11193.  
  11194.  
  11195.           VIDEOMODEGET
  11196.  
  11197.             PROTOTYPE
  11198.  
  11199.             extern int far videomodeget (void)
  11200.  
  11201.             INPUT
  11202.  
  11203.             no input parameters
  11204.  
  11205.             OUTPUT
  11206.  
  11207.             the current video mode
  11208.  
  11209.             USAGE
  11210.  
  11211.             VIDEOMODEGET returns the current video mode.  This function is
  11212.             best used to retrieve the video mode being used when a program
  11213.             begins.  When the program ends, this video mode can then be
  11214.             restored using VIDEOMODESET.
  11215.  
  11216.             SEE ALSO
  11217.  
  11218.             RES320, RES640, RES640L, RES800, RES1024, RES1280, RESTEXT,
  11219.             VIDEOMODESET
  11220.  
  11221.             EXAMPLE
  11222.  
  11223.             /*
  11224.              * save the current video mode, enable 640x480x256, and reset
  11225.             the video mode
  11226.              */
  11227.  
  11228.             #include <stdlib.h>
  11229.             #include <conio.h>
  11230.             #include "svgacc.h"
  11231.  
  11232.             void main(void)
  11233.             {
  11234.                int vmode;
  11235.  
  11236.                vmode = videomodeget();
  11237.                if ( !whichvga() )
  11238.                  exit(1);
  11239.                if ( whichmem() < 512)
  11240.                  exit(1);
  11241.                res640();
  11242.                videomodeset(vmode);
  11243.                printf("we are back!");
  11244.                getch();
  11245.                exit(0);
  11246.             }
  11247.  
  11248.  
  11249.  
  11250.  
  11251.                                                                         180
  11252.  
  11253.  
  11254.  
  11255.  
  11256.  
  11257.           VIDEOMODESET
  11258.  
  11259.             PROTOTYPE
  11260.  
  11261.             extern void far videomodeset (int videomode)
  11262.  
  11263.             INPUT
  11264.  
  11265.             mode - number of video mode
  11266.  
  11267.             OUTPUT
  11268.  
  11269.             no value returned
  11270.  
  11271.             USAGE
  11272.  
  11273.             VIDEOMODESET sets the video mode specified by mode.  This
  11274.             function is best used at the end of a program to restore the
  11275.             video mode to the mode in use when the program began.  The
  11276.             program should retrieve the video mode at the beginning by
  11277.             using VIDEOMODEGET.
  11278.  
  11279.             SEE ALSO
  11280.  
  11281.             RES320, RES640, RES640L, RES800, RES1024, RES1280, RESTEXT,
  11282.             VIDEOMODEGET
  11283.  
  11284.             EXAMPLE
  11285.  
  11286.             See VIDEMODEGET
  11287.  
  11288.  
  11289.  
  11290.  
  11291.  
  11292.  
  11293.  
  11294.  
  11295.  
  11296.  
  11297.  
  11298.  
  11299.  
  11300.  
  11301.  
  11302.  
  11303.  
  11304.  
  11305.  
  11306.  
  11307.  
  11308.  
  11309.  
  11310.  
  11311.  
  11312.  
  11313.                                                                         181
  11314.  
  11315.  
  11316.  
  11317.  
  11318.  
  11319.           VIDEOOFF
  11320.  
  11321.             PROTOTYPE
  11322.  
  11323.             extern void far videooff (void)
  11324.  
  11325.             INPUT
  11326.  
  11327.             no input parameters
  11328.  
  11329.             OUTPUT
  11330.  
  11331.             no value returned
  11332.  
  11333.             USAGE
  11334.  
  11335.             VIDEOOFF turns the output display off.  Graphics may still be
  11336.             drawn to the screen.  However, the computer's monitor will
  11337.             display nothing and appear black.  This function can be used
  11338.             to hide graphics being drawn by initially using VIDEOOFF and
  11339.             then later calling VIDEOON.
  11340.  
  11341.             SEE ALSO
  11342.  
  11343.             VIDEOON
  11344.  
  11345.             EXAMPLE
  11346.  
  11347.             /*
  11348.              * disable the video for about 3 seconds, then enable it
  11349.              */
  11350.  
  11351.             #include <stdlib.h>
  11352.             #include <conio.h>
  11353.             #include "svgacc.h"
  11354.  
  11355.             void main(void)
  11356.             {
  11357.                int vmode;
  11358.  
  11359.                printf("press a key to disable video for 3 seconds...");
  11360.                getch();
  11361.                videooff();
  11362.                sdelay(195);
  11363.                videoon();
  11364.                videomodeset(vmode);
  11365.                printf("we are back!");
  11366.                getch();
  11367.                exit(0);
  11368.             }
  11369.  
  11370.  
  11371.  
  11372.  
  11373.  
  11374.  
  11375.                                                                         182
  11376.  
  11377.  
  11378.  
  11379.  
  11380.  
  11381.           VIDEOON
  11382.  
  11383.             PROTOTYPE
  11384.  
  11385.             extern void far videoon (void)
  11386.  
  11387.             INPUT
  11388.  
  11389.             no input parameters
  11390.  
  11391.             OUTPUT
  11392.  
  11393.             no value returned
  11394.  
  11395.             USAGE
  11396.  
  11397.             VIDEOON turns the display on.  All graphics that were drawn
  11398.             while the display was off are now visible.  This function can
  11399.             be used to hide graphics being drawn by initially using
  11400.             VIDEOOFF and then later calling VIDEOON.
  11401.  
  11402.             SEE ALSO
  11403.  
  11404.             VIDEOOFF
  11405.  
  11406.             EXAMPLE
  11407.  
  11408.             See VIDEOOFF
  11409.  
  11410.  
  11411.  
  11412.  
  11413.  
  11414.  
  11415.  
  11416.  
  11417.  
  11418.  
  11419.  
  11420.  
  11421.  
  11422.  
  11423.  
  11424.  
  11425.  
  11426.  
  11427.  
  11428.  
  11429.  
  11430.  
  11431.  
  11432.  
  11433.  
  11434.  
  11435.  
  11436.  
  11437.                                                                         183
  11438.  
  11439.  
  11440.  
  11441.  
  11442.  
  11443.           WHICHCPU
  11444.  
  11445.             PROTOTYPE
  11446.  
  11447.             extern int far whichcpu (void)
  11448.  
  11449.             INPUT
  11450.  
  11451.             no input parameters
  11452.  
  11453.             OUTPUT
  11454.  
  11455.             processor type
  11456.  
  11457.             USAGE
  11458.  
  11459.             WHICHCPU returns the computer's processor type as 86, 286,
  11460.             386, 486 or 586.  This function should be called by any
  11461.             program using this library's routines to insure that the
  11462.             computer is at least 386 compatible or better.
  11463.  
  11464.             SEE ALSO
  11465.  
  11466.             WHICHJOYSTICK, WHICHMOUSE, WHICHVGA
  11467.  
  11468.             EXAMPLE
  11469.  
  11470.             /*
  11471.              * id the microprocessor
  11472.              */
  11473.  
  11474.             #include <stdlib.h>
  11475.             #include <conio.h>
  11476.             #include "svgacc.h"
  11477.  
  11478.             void main(void)
  11479.             {
  11480.                int vmode;
  11481.                int cpu;
  11482.  
  11483.                cpu = whichcpu();
  11484.                printf("Microprocessor is identified as an 80%d.\n", cpu);
  11485.                getch();
  11486.                exit(0);
  11487.             }
  11488.  
  11489.  
  11490.  
  11491.  
  11492.  
  11493.  
  11494.  
  11495.  
  11496.  
  11497.  
  11498.  
  11499.                                                                         184
  11500.  
  11501.  
  11502.  
  11503.  
  11504.  
  11505.           WHICHJOYSTICK
  11506.  
  11507.             PROTOTYPE
  11508.  
  11509.             extern int far whichjoystick (void)
  11510.  
  11511.             INPUT
  11512.  
  11513.             no input parameters
  11514.  
  11515.             OUTPUT
  11516.  
  11517.             available joystick support
  11518.  
  11519.             USAGE
  11520.  
  11521.             WHICHJOYSTICK returns the joystick support available on the
  11522.             computer.  This function should be called prior to use of the
  11523.             joysticks to verify that joysticks are available.  If the
  11524.             function returns a -1, there is no joystick port present or no
  11525.             BIOS support for a joystick.  Joystick A is bit 1 and B is bit
  11526.             2.  Therefore, a return value of 1 means joystick A is
  11527.             available, a value of 2 means B is available and a value of 3
  11528.             means both are available.  If no bits are set, there are no
  11529.             joysticks present.
  11530.  
  11531.             SEE ALSO
  11532.  
  11533.             JOYSTICKINFO, WHICHCPU, WHICHMOUSE, WHICHVGA
  11534.  
  11535.             EXAMPLE
  11536.  
  11537.             /* id any joysticks */
  11538.             #include <stdlib.h>
  11539.             #include "svgacc.h"
  11540.  
  11541.             void main(void)
  11542.             {
  11543.                int vmode, joystick;
  11544.  
  11545.                joystick = whichjoystick();
  11546.                switch (joystick) {
  11547.                  case -1:
  11548.                     printf("No joystick port detected or no joystick BIOS
  11549.             support present.\n\n");
  11550.                     break;
  11551.                  case 0:
  11552.                     printf("No joystick detected\n\n");
  11553.                     break;
  11554.                  case 1:
  11555.                     printf("Joystick A is present and available.\n\n");
  11556.                     break;
  11557.                  case 2:
  11558.                     printf("Joystick B is present and available.\n\n");
  11559.  
  11560.  
  11561.                                                                         185
  11562.  
  11563.  
  11564.  
  11565.  
  11566.  
  11567.                     break;
  11568.                  case 3:
  11569.                     printf("Both Joystick A and Joystick B are
  11570.             present.\n\n");
  11571.                     break;
  11572.                }
  11573.             }
  11574.  
  11575.  
  11576.  
  11577.  
  11578.  
  11579.  
  11580.  
  11581.  
  11582.  
  11583.  
  11584.  
  11585.  
  11586.  
  11587.  
  11588.  
  11589.  
  11590.  
  11591.  
  11592.  
  11593.  
  11594.  
  11595.  
  11596.  
  11597.  
  11598.  
  11599.  
  11600.  
  11601.  
  11602.  
  11603.  
  11604.  
  11605.  
  11606.  
  11607.  
  11608.  
  11609.  
  11610.  
  11611.  
  11612.  
  11613.  
  11614.  
  11615.  
  11616.  
  11617.  
  11618.  
  11619.  
  11620.  
  11621.  
  11622.  
  11623.                                                                         186
  11624.  
  11625.  
  11626.  
  11627.  
  11628.  
  11629.           WHICHMEM
  11630.  
  11631.             PROTOTYPE
  11632.  
  11633.             extern int far whichmem (void)
  11634.  
  11635.             INPUT
  11636.  
  11637.             no input parameters
  11638.  
  11639.             OUTPUT
  11640.  
  11641.             installed video memory in kilobytes
  11642.  
  11643.             USAGE
  11644.  
  11645.             WHICHMEM returns the amount of installed video memory as
  11646.             previously determined by WHICHVGA.  WHICHVGA should be called
  11647.             prior to WHICHMEM.  This function should be called prior to
  11648.             any of the RES### functions to verify that there is enough
  11649.             memory to support the desired resolution.  If SETCARD was used
  11650.             to set the video card and memory, WHICHMEM will return the
  11651.             amount of memory as defined by SETCARD.
  11652.  
  11653.             SEE ALSO
  11654.  
  11655.             RES320, RES640, RES640L, RES800, RES1024, RES1280, SETCARD,
  11656.             WHICHVGA
  11657.  
  11658.             EXAMPLE
  11659.  
  11660.             /*
  11661.              * id the video memory
  11662.              */
  11663.  
  11664.             #include <stdlib.h>
  11665.             #include <conio.h>
  11666.             #include "svgacc.h"
  11667.  
  11668.             void main(void)
  11669.             {
  11670.                int vmode, vga, mem;
  11671.  
  11672.                vga = whichvga();
  11673.                mem = whichmem();
  11674.                printf("Installed video memory is %d k.\n", mem);
  11675.                getch();
  11676.                exit(0);
  11677.             }
  11678.  
  11679.  
  11680.  
  11681.  
  11682.  
  11683.  
  11684.  
  11685.                                                                         187
  11686.  
  11687.  
  11688.  
  11689.  
  11690.  
  11691.           WHICHMOUSE
  11692.  
  11693.             PROTOTYPE
  11694.  
  11695.             extern int far whichmouse (void)
  11696.  
  11697.             INPUT
  11698.  
  11699.             no input parameters
  11700.  
  11701.             OUTPUT
  11702.  
  11703.             number of buttons on mouse
  11704.  
  11705.             USAGE
  11706.  
  11707.             WHICHMOUSE returns a value indicating whether a Microsoft
  11708.             compatible mouse is available.  If the function returns a 0,
  11709.             no mouse is available.  A non zero value indicates a mouse and
  11710.             Microsoft compatible driver are installed and gives the number
  11711.             of buttons (2 or 3) available.
  11712.  
  11713.             SEE ALSO
  11714.  
  11715.             MOUSEINFO, WHICHCPU, WHICHJOYSTICK, WHICHVGA
  11716.  
  11717.             EXAMPLE
  11718.  
  11719.             See MOUSEINFO
  11720.  
  11721.  
  11722.  
  11723.  
  11724.  
  11725.  
  11726.  
  11727.  
  11728.  
  11729.  
  11730.  
  11731.  
  11732.  
  11733.  
  11734.  
  11735.  
  11736.  
  11737.  
  11738.  
  11739.  
  11740.  
  11741.  
  11742.  
  11743.  
  11744.  
  11745.  
  11746.  
  11747.                                                                         188
  11748.  
  11749.  
  11750.  
  11751.  
  11752.  
  11753.           WHICHVGA
  11754.  
  11755.             PROTOTYPE
  11756.  
  11757.             extern VGAChipset far whichvga (void)
  11758.  
  11759.             INPUT
  11760.  
  11761.             no input parameters
  11762.  
  11763.             OUTPUT
  11764.  
  11765.             WHICHVGA returns a code identifying the video card.
  11766.  
  11767.             USAGE
  11768.  
  11769.             WHICHVGA identifies the video card installed and the amount of
  11770.             video memory.  In addition this function sets up the default
  11771.             font and mouse cursor.  This function must be called before
  11772.             any other graphics function.  The code returned identifies the
  11773.             video card according to the following table:
  11774.  
  11775.           1  Acumos AVGA2/3 SuperVGA
  11776.           2  ATI Technologies 18/28/38/68800
  11777.              SuperVGA
  11778.           3  Ahead V5000 ver A SuperVGA
  11779.           4  Ahead V5000 ver B SuperVGA
  11780.           5  Chips and Technologies 82C45x SuperVGA
  11781.           6  Cirrus Logic CL-GD 5xx, 6xx, 28xx,
  11782.              54xx, 62xx SuperVGA
  11783.           7  Everex Micro Enhancer Ev236/6xx
  11784.              SuperVGA
  11785.           8  Genoa 61/62/63/64/6600 SuperVGA
  11786.           9  NCR 77C21/22/22E/22E+ SuperVGA
  11787.           10 Oak Technologies OTI-037C/067/077/087
  11788.              SuperVGA
  11789.           11 Paradise/Western Digital PVGA1A,
  11790.              WD90C00/1x/2x/3x SuperVGA
  11791.           12 Realtek RT3106 SuperVGA
  11792.           13 Trident 8800CS, 8900B/C/CL/CX, 90x0
  11793.              SuperVGA
  11794.           14 Tseng Labs ET3000-AX/BX/BP SuperVGA
  11795.           15 Tseng Labs ET4000/W32/W32I SuperVGA
  11796.           16 VESA compatible SuperVGA
  11797.           17 Video 7 HT-208/16 SuperVGA
  11798.           18 Avance Logic AL2101 SuperVGA
  11799.           19 MXIC MX68000/10 SuperVGA
  11800.           20 Primus P2000 SuperVGA
  11801.  
  11802.             Any value returned not found on this table represents an
  11803.             unidentified video card.
  11804.  
  11805.             No graphics functions should be called unless the video card
  11806.             is properly identified.
  11807.  
  11808.  
  11809.                                                                         189
  11810.  
  11811.  
  11812.  
  11813.  
  11814.  
  11815.  
  11816.             SEE ALSO
  11817.  
  11818.             SETCARD, WHICHCPU, WHICHJOYSTICK, WHICHMOUSE, WHICHMEM
  11819.  
  11820.             EXAMPLE
  11821.  
  11822.             /*
  11823.              * id the svga
  11824.              */
  11825.  
  11826.             #include <stdlib.h>
  11827.             #include <conio.h>
  11828.             #include "svgacc.h"
  11829.  
  11830.             void main(void)
  11831.             {
  11832.  
  11833.             char buf[40];
  11834.  
  11835.             switch(whichvga()) {
  11836.                case ACUMOS:
  11837.                  sprintf(buf,"Acumos AVGA2/3 SuperVGA");
  11838.                  break;
  11839.                case ATI:
  11840.                  sprintf(buf,"ATI Technologies 18/28/38/68800 SuperVGA");
  11841.                  break;
  11842.                case AHEADA:
  11843.                  sprintf(buf,"Ahead V5000 Ver A SuperVGA");
  11844.                  break;
  11845.                case AHEADB:
  11846.                  sprintf(buf,"Ahead V5000 Ver B SuperVGA");
  11847.                  break;
  11848.                case CHIPSTECH:
  11849.                  sprintf(buf,"Chips and Technologies 82C450/1/2/3/5/6/7
  11850.           SuperVGA");
  11851.                  break;
  11852.                case CIRRUS:
  11853.                  sprintf(buf,"Cirrus Logic CL-GD 5xx,6xx,28xx,54xx,62xx
  11854.           SuperVGA");
  11855.                  break;
  11856.                case EVEREX:
  11857.                  sprintf(buf,"Everex EV236/6xx Micro Enhancer SuperVGA");
  11858.                  break;
  11859.                case GENOA:
  11860.                  sprintf(buf,"Genoa 61/62/63/64/6600 SuperVGA");
  11861.                  break;
  11862.                case NCR:
  11863.                  sprintf(buf,"NCR 77C21/22/22E/22E+ SuperVGA");
  11864.                  break;
  11865.                case OAKTECH:
  11866.                  sprintf(buf,"Oak Technologies OTI-037/67/77/87C
  11867.           SuperVGA");
  11868.                  break;
  11869.  
  11870.  
  11871.                                                                         190
  11872.  
  11873.  
  11874.  
  11875.  
  11876.  
  11877.                case PARADISE:
  11878.                  sprintf(buf,"Paradise/Western Digital
  11879.           PVGA1A,WD90C00/1x/2x/3x SuperVGA");
  11880.                  break;
  11881.                case REALTEK:
  11882.                  sprintf(buf,"Realtek RT3106 SuperVGA");
  11883.                  break;
  11884.                case TRIDENT:
  11885.                  sprintf(buf,"Trident 8800CS,8900B/C/CL/CX,90x0
  11886.           SuperVGA");
  11887.                  break;
  11888.                case TSENG3:
  11889.                  sprintf(buf,"Tseng Labs ET3000-AX/BX/BP SuperVGA");
  11890.                  break;
  11891.                case TSENG4:
  11892.                  sprintf(buf,"Tseng Labs ET4000/W32/W32I SuperVGA");
  11893.                  break;
  11894.                case VESA:
  11895.                  sprintf(buf,"VESA compatible SuperVGA");
  11896.                  break;
  11897.                case VIDEO7:
  11898.                  sprintf(buf,"Video 7 HT-208/16 SuperVGA");
  11899.                  break;
  11900.                case AVANCE:
  11901.                  sprintf(buf,"Avance Logic AL2101 SuperVGA");
  11902.                  break;
  11903.                case MXIC:
  11904.                  sprintf(buf,"MXIC MX68000/10 SuperVGA");
  11905.                  break;
  11906.                case PRIMUS:
  11907.                  sprintf(buf,"Primus P2000 SuperVGA");
  11908.                  break;
  11909.                default:
  11910.                  printf("Sorry, unable to identify video card or it is not
  11911.           a SuperVGA video adapter.\n");
  11912.                  exit(0);
  11913.             }
  11914.             printf("Video card/chip is identified as %s.\n",&buf);
  11915.             exit(0);
  11916.           }
  11917.  
  11918.  
  11919.  
  11920.  
  11921.  
  11922.  
  11923.  
  11924.  
  11925.  
  11926.  
  11927.  
  11928.  
  11929.  
  11930.  
  11931.  
  11932.  
  11933.                                                                         191
  11934.  
  11935.  
  11936.  
  11937.  
  11938.  
  11939.           WHICHXMS
  11940.  
  11941.             PROTOTYPE
  11942.  
  11943.             extern int far whichxms (unsigned int far *xmskbytesavail,
  11944.             unsigned int far *xmshandlesavail)
  11945.  
  11946.             INPUT
  11947.  
  11948.             no input parameters
  11949.  
  11950.             OUTPUT
  11951.  
  11952.             WHICHXMS returns a 1 if extended memory support is detected, 0
  11953.             otherwise.
  11954.             xmskbytesavail - number of free kilobytes in extended memory
  11955.             xmshandlesavail - number of available free handles
  11956.  
  11957.             USAGE
  11958.  
  11959.             WHICHXMS detects the existence of extended memory support and
  11960.             sets up the library function calls.  This function must be
  11961.             called before any other extended memory functions.  WHICHXMS
  11962.             also returns the number of free kilobytes of extended memory
  11963.             and the number of available handles.  The number of available
  11964.             handles is limited, normally to 32.  This limit can be
  11965.             modified by changing the extended memory driver (Microsoft's
  11966.             HIMEM.SYS is the most common) command line in the CONFIG.SYS
  11967.             file.
  11968.  
  11969.             SEE ALSO
  11970.  
  11971.             XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSGET, XMSPUT
  11972.  
  11973.             EXAMPLE
  11974.  
  11975.             /*
  11976.              * show what xms memory is available
  11977.              */
  11978.  
  11979.             #include <stdlib.h>
  11980.             #include <conio.h>
  11981.             #include "svgacc.h"
  11982.  
  11983.             void main(void)
  11984.             {
  11985.                int er, mem, handles;
  11986.  
  11987.                if ( whichxms(&mem,&handles) ) {
  11988.                  printf("an active xms memory manager was found!\n");
  11989.                  printf("a total of %d kb of xms memory
  11990.             available...\n",mem);
  11991.                  printf("a total of %d xms memory handles
  11992.             available...\n",handles);
  11993.  
  11994.  
  11995.                                                                         192
  11996.  
  11997.  
  11998.  
  11999.  
  12000.  
  12001.                  printf(" \n");
  12002.                  if ((mem < 1) || (handles < 1)) {
  12003.                     printf("sorry...there is either no free xms or\n");
  12004.                     printf("no free handles\n");
  12005.                     printf(" \n");
  12006.                     printf("xms support not available...\n");
  12007.                     exit(1);
  12008.                  }
  12009.                  else {
  12010.                  printf(" \n");
  12011.                  printf("xms support is ready and available!\n");
  12012.                  exit(1);
  12013.                  }
  12014.                }
  12015.                else {
  12016.                  printf("sorry...no active xms memory manager
  12017.             found...\n");
  12018.                  printf("make sure you have an xms memory manager\n");
  12019.                  printf("(such as HIMEM.SYS) loaded\n");
  12020.                  printf(" \n");
  12021.                  printf("xms support not available...\n");
  12022.                  exit(1);
  12023.                }
  12024.  
  12025.                exit(0);
  12026.             }
  12027.  
  12028.  
  12029.  
  12030.  
  12031.  
  12032.  
  12033.  
  12034.  
  12035.  
  12036.  
  12037.  
  12038.  
  12039.  
  12040.  
  12041.  
  12042.  
  12043.  
  12044.  
  12045.  
  12046.  
  12047.  
  12048.  
  12049.  
  12050.  
  12051.  
  12052.  
  12053.  
  12054.  
  12055.  
  12056.  
  12057.                                                                         193
  12058.  
  12059.  
  12060.  
  12061.  
  12062.  
  12063.           XMSALLOCATE
  12064.  
  12065.             PROTOTYPE
  12066.  
  12067.             extern int far xmsallocate (unsigned int reqkbytes)
  12068.  
  12069.             INPUT
  12070.  
  12071.             reqkbytes - requested number of kilobytes of extended memory
  12072.  
  12073.             OUTPUT
  12074.  
  12075.             XMSALLOCATE returns the assigned memory handle if the
  12076.             allocation is successful, 0 otherwise.
  12077.  
  12078.             USAGE
  12079.  
  12080.             XMSALLOCATE attempts to allocate the requested number of
  12081.             kilobytes in extended memory.  If successful, the function
  12082.             returns the handle of the new memory block.  If the function
  12083.             returns zero, then the allocation was unsuccessful; check
  12084.             XMSERROR for error codes.
  12085.  
  12086.             All allocated blocks must be freed using XMSFREE before a
  12087.             program terminates or the memory is lost until the machine is
  12088.             rebooted.  Simply exiting a program will not free allocated
  12089.             extended memory blocks.
  12090.  
  12091.             SEE ALSO
  12092.  
  12093.             WHICHXMS, XMSCOPY, XMSERROR, XMSFREE, XMSGET, XMSPUT,
  12094.             XMSSCREENGET, XMSSCREENPUT
  12095.  
  12096.             EXAMPLE
  12097.  
  12098.             See XMSCOPY
  12099.  
  12100.  
  12101.  
  12102.  
  12103.  
  12104.  
  12105.  
  12106.  
  12107.  
  12108.  
  12109.  
  12110.  
  12111.  
  12112.  
  12113.  
  12114.  
  12115.  
  12116.  
  12117.  
  12118.  
  12119.                                                                         194
  12120.  
  12121.  
  12122.  
  12123.  
  12124.  
  12125.           XMSBLKGET
  12126.  
  12127.             PROTOTYPE
  12128.  
  12129.             extern int far xmsblkget (int x1, int y1, int x2, int y2)
  12130.  
  12131.             INPUT
  12132.  
  12133.             x1, y1 - top left corner of block
  12134.             x2, y2 - bottom right corner of block
  12135.  
  12136.             OUTPUT
  12137.  
  12138.             Used as a function, XMSBLKGET returns the assigned XMS memory
  12139.             handle if successful, 0 otherwise.
  12140.  
  12141.             USAGE
  12142.  
  12143.             XMSBLKGET stores the pixel data contained within the block
  12144.             defined by (x1, y1)-(x2, y2) in extended memory.  A minimum of
  12145.             32k of XMS memory will be allocated regardless of the size of
  12146.             the graphics  block.  Note that XMSBLKGET enforces x2>x1 and
  12147.             y2>y1.  Also, the coordinates must be valid on the screen at
  12148.             the current resolution.  The bitmap is stored such that the
  12149.             first integer in the allocated XMS block is the width and the
  12150.             second integer is the height.  These are followed by a long
  12151.             integer (4 bytes) that specifies the total size of the
  12152.             allocated XMS block.  The remaining bytes are the bitmap
  12153.             raster data stored by rows starting at the top of the block.
  12154.             If the function was unsuccessful, check XMSERROR for error
  12155.             codes.
  12156.  
  12157.             All allocated XMS blocks must be freed using XMSFREE before a
  12158.             program terminates or the memory is lost until the machine is
  12159.             rebooted.  Simply exiting a program will not free allocated
  12160.             extended memory blocks.
  12161.  
  12162.             SEE ALSO
  12163.  
  12164.             BLKGET, BLKPUT, XMSBLKPUT, XMSERROR, XMSFREE, XMSSCREENGET,
  12165.             XMSSCREENPUT
  12166.  
  12167.             EXAMPLE
  12168.  
  12169.             /*
  12170.              * this will copy a larger graphics block (about 80k)
  12171.              * from one part of the screen to another using xms memory
  12172.              */
  12173.  
  12174.             #include <stdlib.h>
  12175.             #include <conio.h>
  12176.             #include "svgacc.h"
  12177.             #define randnum(size) (rand() % (int)(size))
  12178.  
  12179.  
  12180.  
  12181.                                                                         195
  12182.  
  12183.  
  12184.  
  12185.  
  12186.  
  12187.             void main(void)
  12188.             {
  12189.                int i, handle, er, mem, handles,x1,y1,x2,y2,colr;
  12190.  
  12191.                /* make sure xms is ready and available */
  12192.                if ( whichxms(&mem,&handles) ) {
  12193.                  if ((mem < 1) || (handles < 1)) {
  12194.                     printf("sorry...there is either no free xms or\n");
  12195.                     printf("no free handles\n");
  12196.                     exit(1);
  12197.                  }
  12198.                }
  12199.                else {
  12200.                  printf("sorry...no active xms memory manager
  12201.             found...\n");
  12202.                  printf("make sure you have an xms memory manager\n");
  12203.                  printf("(such as HIMEM.SYS) loaded\n");
  12204.                  exit(1);
  12205.                }
  12206.  
  12207.                if ( !whichvga() )
  12208.                  exit(1);
  12209.                if ( !res640() )
  12210.                  exit(1);
  12211.                drwfillbox(SET,10,0,0,200,400);
  12212.                for(i=0;i<=200;i++)
  12213.                {
  12214.                  x1 = randnum(200);
  12215.                  y1 = randnum(400);
  12216.                  x2 = randnum(200);
  12217.                  y2 = randnum(400);
  12218.                  colr = randnum(16);
  12219.                  drwline(1,colr,x1,y1,x2,y2);
  12220.                }
  12221.                drwbox(SET,15,0,0,200,400);
  12222.                handle = xmsblkget(0,0,200,400);
  12223.                if ( !handle ) {
  12224.                  printf("opps there is some error...unable to allocate
  12225.             xms...\n");
  12226.                  printf("error # %d\n",xmserror());
  12227.                  er = xmsfree(handle);
  12228.                  exit(1);
  12229.                }
  12230.                er = xmsblkput(SET,175,75,handle);
  12231.                er = xmsfree(handle);
  12232.  
  12233.                getch();
  12234.                restext();
  12235.                exit(0);
  12236.             }
  12237.  
  12238.  
  12239.  
  12240.  
  12241.  
  12242.  
  12243.                                                                         196
  12244.  
  12245.  
  12246.  
  12247.  
  12248.  
  12249.           XMSBLKPUT
  12250.  
  12251.             PROTOTYPE
  12252.  
  12253.             extern int far xmsblkput (int mode, int x, int y, int
  12254.             srcxmshandle)
  12255.  
  12256.             INPUT
  12257.  
  12258.             mode - pixel write mode (SET=1, XOR=2, OR=3, AND=4)
  12259.             x, y - location for top left corner of block
  12260.             srcxmshandle - handle of source extended memory block
  12261.  
  12262.             OUTPUT
  12263.  
  12264.             Used as a function, XMSBLKPUT returns a 1 if successful, 0
  12265.             otherwise.
  12266.  
  12267.             USAGE
  12268.  
  12269.             XMSBLKPUT places the pixel data contained in XMS memory
  12270.             referenced by srcxmshandle on the screen.  The top, left
  12271.             corner of the block is specified by (x, y).  Any (x, y) is
  12272.             acceptable and any portion of the block that lies outside of
  12273.             the currently defined viewport will not be drawn.  If the
  12274.             function was unsuccessful, check XMSERROR for error codes.
  12275.  
  12276.             All allocated XMS blocks must be freed using XMSFREE before a
  12277.             program terminates or the memory is lost until the machine is
  12278.             rebooted.  Simply exiting a program will not free allocated
  12279.             extended memory blocks.
  12280.  
  12281.             SEE ALSO
  12282.  
  12283.             BLKGET, BLKPUT, XMSBLKGET, XMSERROR, XMSFREE, XMSSCREENGET,
  12284.             XMSSCREENPUT
  12285.  
  12286.             EXAMPLE
  12287.  
  12288.             See XMSBLKGET
  12289.  
  12290.  
  12291.  
  12292.  
  12293.  
  12294.  
  12295.  
  12296.  
  12297.  
  12298.  
  12299.  
  12300.  
  12301.  
  12302.  
  12303.  
  12304.  
  12305.                                                                         197
  12306.  
  12307.  
  12308.  
  12309.  
  12310.  
  12311.           XMSCOPY
  12312.  
  12313.             PROTOTYPE
  12314.  
  12315.             extern int far xmscopy (int xmssrchandle, long srcoffset, int
  12316.             xmsdesthandle, long destoffset, unsigned long count)
  12317.  
  12318.             INPUT
  12319.  
  12320.             xmssrchandle - handle of source extended memory block
  12321.             srcoffset - number of bytes from beginning of source memory
  12322.             block
  12323.             xmsdesthandle - handle of destination extended memory block
  12324.             destoffset - number of bytes from beginning of destination
  12325.             memory block
  12326.             count - number of bytes to copy from source to destination
  12327.             (must be even)
  12328.  
  12329.             OUTPUT
  12330.  
  12331.             XMSCOPY returns a 1 if copy was successful, 0 otherwise.
  12332.  
  12333.             USAGE
  12334.  
  12335.             XMSCOPY copies the number of bytes specified in count from the
  12336.             source extended memory block to the destination extended
  12337.             memory block.  Count must be an even number.  The copy may
  12338.             begin and/or end offset from the beginning of the source and
  12339.             destination blocks by passing non zero values in srcoffset
  12340.             and/or destoffset.  The copy will occur faster if both offsets
  12341.             are divisible by four.  If the copy was unsuccessful, check
  12342.             XMSERROR for error codes.
  12343.  
  12344.             SEE ALSO
  12345.  
  12346.             WHICHXMS, XMSALLOCATE, XMSERROR, XMSFREE, XMSGET, XMSPUT
  12347.  
  12348.             EXAMPLE
  12349.  
  12350.             /*
  12351.              * show xms functions: this will copy one array into one
  12352.              * xms block, copy that xms block to a second xms block,
  12353.              * and then copy that second xms block to another array
  12354.              */
  12355.  
  12356.             #include <stdlib.h>
  12357.             #include <conio.h>
  12358.             #include "svgacc.h"
  12359.  
  12360.             void main(void)
  12361.             {
  12362.                int i, handle1, handle2, er, mem, handles;
  12363.                int test1[10], test2[10];
  12364.  
  12365.  
  12366.  
  12367.                                                                         198
  12368.  
  12369.  
  12370.  
  12371.  
  12372.  
  12373.                /* make sure xms is ready and available */
  12374.                if ( whichxms(&mem,&handles) ) {
  12375.                  if ((mem < 1) || (handles < 1)) {
  12376.                     printf("sorry...there is either no free xms or\n");
  12377.                     printf("no free handles\n");
  12378.                     exit(1);
  12379.                  }
  12380.                }
  12381.                else {
  12382.                  printf("sorry...no active xms memory manager
  12383.             found...\n");
  12384.                  printf("make sure you have an xms memory manager\n");
  12385.                  printf("(such as HIMEM.SYS) loaded\n");
  12386.                  exit(1);
  12387.                }
  12388.  
  12389.                /* generate some data */
  12390.                for(i=0;i<10;i++)
  12391.                {
  12392.                  test1[i] = i;
  12393.                }
  12394.  
  12395.                /* allocate the first xms block */
  12396.                handle1 = xmsallocate(1);
  12397.                if ( !handle1 ) {
  12398.                  printf("opps there is some error...unable to allocate
  12399.             xms...\n");
  12400.                  printf("error # %d\n",xmserror());
  12401.                  er = xmsfree(handle1);
  12402.                  exit(1);
  12403.                }
  12404.  
  12405.                /* allocate the second xms block */
  12406.                handle2 = xmsallocate(1);
  12407.                if ( !handle2 ) {
  12408.                  printf("opps there is some error...unable to allocate
  12409.             xms...\n");
  12410.                  printf("error # %d\n",xmserror());
  12411.                  er = xmsfree(handle1);
  12412.                  er = xmsfree(handle2);
  12413.                  exit(1);
  12414.                }
  12415.  
  12416.                /* copy our source array into first xms block */
  12417.                er = xmsput (test1, handle1, 0, sizeof(test1));
  12418.                if ( !er ) {
  12419.                  printf("opps there is some error...see error code
  12420.             list...\n");
  12421.                  printf("error # %d\n",xmserror());
  12422.                  er = xmsfree(handle1);
  12423.                  er = xmsfree(handle2);
  12424.                  exit(1);
  12425.                }
  12426.  
  12427.  
  12428.  
  12429.                                                                         199
  12430.  
  12431.  
  12432.  
  12433.  
  12434.  
  12435.                /* copy first xms block into second xms block */
  12436.                er = xmscopy (handle1, 0, handle2, 0, sizeof(test1));
  12437.                if ( !er ) {
  12438.                  printf("opps there is some error...see error code
  12439.             list...\n");
  12440.                  printf("error # %d\n",xmserror());
  12441.                  er = xmsfree(handle1);
  12442.                  er = xmsfree(handle2);
  12443.                  exit(1);
  12444.                }
  12445.  
  12446.                /* copy second xms block to out destination array */
  12447.                er = xmsget (handle2, 0, test2, sizeof(test1));
  12448.                if ( !er ) {
  12449.                  printf("opps there is some error...see error code
  12450.             list...\n");
  12451.                  printf("error # %d\n",xmserror());
  12452.                  er = xmsfree(handle1);
  12453.                  er = xmsfree(handle2);
  12454.                  exit(1);
  12455.                }
  12456.  
  12457.                /* free up all the xms memory we have allocated */
  12458.                er = xmsfree(handle1);
  12459.                er = xmsfree(handle2);
  12460.  
  12461.                /* show the results */
  12462.                printf("ok...we initialized one array with data, copied
  12463.             that\n");
  12464.                printf("array to an xms block, copied that xms block to
  12465.             a\n");
  12466.                printf("second xms block, and finally copied the second
  12467.             xms\n");
  12468.                printf("block into a new array...here are the results:\n");
  12469.                printf(" \n");
  12470.                printf("source array         destination array\n");
  12471.                for(i=0;i<10;i++)
  12472.                {
  12473.                printf(" %d                    %d\n",test1[i],test2[i]);
  12474.                }
  12475.                exit(0);
  12476.             }
  12477.  
  12478.  
  12479.  
  12480.  
  12481.  
  12482.  
  12483.  
  12484.  
  12485.  
  12486.  
  12487.  
  12488.  
  12489.  
  12490.  
  12491.                                                                         200
  12492.  
  12493.  
  12494.  
  12495.  
  12496.  
  12497.           XMSERROR
  12498.  
  12499.             PROTOTYPE
  12500.  
  12501.             extern int far xmserror (void)
  12502.  
  12503.             INPUT
  12504.  
  12505.             no input parameters
  12506.  
  12507.             OUTPUT
  12508.  
  12509.             XMSERROR returns the error code from the most recent XMS
  12510.             function call.
  12511.  
  12512.             USAGE
  12513.  
  12514.             XMSERROR returns the error code from the most recent XMS
  12515.             function call.  Each XMS function resets the error code to
  12516.             zero.  Therefore, if there has been an error, the error code
  12517.             should be checked immediately.  The error code will be one of
  12518.             the following:
  12519.  
  12520.             0    no error
  12521.             1    WHICHXMS has not been
  12522.                  called
  12523.             2    number of bytes to
  12524.                  copy is zero
  12525.             3    number of bytes to
  12526.                  copy is odd
  12527.             4    offset into XMS block
  12528.                  is zero
  12529.             128  Function not
  12530.                  implemented
  12531.             129  VDISK device driver
  12532.                  was detected
  12533.             142  General driver error
  12534.             143  Unrecoverable driver
  12535.                  error
  12536.             146  DX is less than
  12537.                  /HMAMIN= parameter
  12538.             160  All extended memory is
  12539.                  allocated
  12540.             161  XMM handles are
  12541.                  exhausted
  12542.             162  Handle is invalid
  12543.             163  Source handle is
  12544.                  invalid
  12545.             164  Source offset is
  12546.                  invalid
  12547.             165  Destination handle is
  12548.                  invalid
  12549.             166  Destination offset is
  12550.                  invalid
  12551.  
  12552.  
  12553.                                                                         201
  12554.  
  12555.  
  12556.  
  12557.  
  12558.  
  12559.             167  Length is invalid
  12560.             168  Overlap in move
  12561.                  request is invalid
  12562.             169  Parity error detected
  12563.             171  Block locked
  12564.  
  12565.             SEE ALSO
  12566.  
  12567.             WHICHXMS, XMSALLOCATE, XMSBLKGET, XMSBLKPUT, XMSCOPY, XMSFREE,
  12568.             XMSGET, XMSPUT, XMSSCREENGET, XMSSCREENPUT
  12569.  
  12570.             EXAMPLE
  12571.  
  12572.             See XMSCOPY
  12573.  
  12574.  
  12575.  
  12576.  
  12577.  
  12578.  
  12579.  
  12580.  
  12581.  
  12582.  
  12583.  
  12584.  
  12585.  
  12586.  
  12587.  
  12588.  
  12589.  
  12590.  
  12591.  
  12592.  
  12593.  
  12594.  
  12595.  
  12596.  
  12597.  
  12598.  
  12599.  
  12600.  
  12601.  
  12602.  
  12603.  
  12604.  
  12605.  
  12606.  
  12607.  
  12608.  
  12609.  
  12610.  
  12611.  
  12612.  
  12613.  
  12614.  
  12615.                                                                         202
  12616.  
  12617.  
  12618.  
  12619.  
  12620.  
  12621.           XMSFREE
  12622.  
  12623.             PROTOTYPE
  12624.  
  12625.             extern int far xmsfree (int xmshandle)
  12626.  
  12627.             INPUT
  12628.  
  12629.             xmshandle - handle of extended memory block to free
  12630.  
  12631.             OUTPUT
  12632.  
  12633.             XMSFREE returns 1 if extended memory block was deallocated, 0
  12634.             otherwise.
  12635.  
  12636.             USAGE
  12637.  
  12638.             XMSFREE deallocates the specified extended memory block.  All
  12639.             allocated blocks must be freed before a program terminates or
  12640.             the memory is lost until the machine is rebooted.  Simply
  12641.             exiting a program will not free allocated extended memory
  12642.             blocks.  If the function was unsuccessful, check XMSERROR for
  12643.             error codes.
  12644.  
  12645.             SEE ALSO
  12646.  
  12647.             WHICHXMS, XMSALLOCATE, XMSBLKGET, XMSBLKPUT, XMSCOPY,
  12648.             XMSERROR, XMSGET, XMSPUT, XMSSCREENGET, XMSSCREENPUT
  12649.  
  12650.             EXAMPLE
  12651.  
  12652.             See XMSCOPY
  12653.  
  12654.  
  12655.  
  12656.  
  12657.  
  12658.  
  12659.  
  12660.  
  12661.  
  12662.  
  12663.  
  12664.  
  12665.  
  12666.  
  12667.  
  12668.  
  12669.  
  12670.  
  12671.  
  12672.  
  12673.  
  12674.  
  12675.  
  12676.  
  12677.                                                                         203
  12678.  
  12679.  
  12680.  
  12681.  
  12682.  
  12683.           XMSGET
  12684.  
  12685.             PROTOTYPE
  12686.  
  12687.             extern int far xmsget (int xmshandle, long offset, void far
  12688.             *destmem, unsigned long count)
  12689.  
  12690.             INPUT
  12691.  
  12692.             xmshandle - handle of source extended memory block
  12693.             offset - number of bytes from beginning of source memory block
  12694.             count - number of bytes to copy from extended memory to
  12695.             conventional memory (must be even)
  12696.  
  12697.             OUTPUT
  12698.  
  12699.             XMSGET returns 1 if the copy was successful, 0 otherwise.
  12700.             destmem - copy of data in conventional memory
  12701.  
  12702.             USAGE
  12703.  
  12704.             XMSGET retrieves data from extended memory and places it in
  12705.             conventional memory.  The number of bytes copied must be an
  12706.             even number and cannot be larger than 65536.  The copy may
  12707.             begin off the beginning of the source extended memory block by
  12708.             specifying an non zero offset.  If the function was
  12709.             unsuccessful, check XMSERROR for error codes.
  12710.  
  12711.             SEE ALSO
  12712.  
  12713.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSPUT
  12714.  
  12715.             EXAMPLE
  12716.  
  12717.             See XMSCOPY
  12718.  
  12719.  
  12720.  
  12721.  
  12722.  
  12723.  
  12724.  
  12725.  
  12726.  
  12727.  
  12728.  
  12729.  
  12730.  
  12731.  
  12732.  
  12733.  
  12734.  
  12735.  
  12736.  
  12737.  
  12738.  
  12739.                                                                         204
  12740.  
  12741.  
  12742.  
  12743.  
  12744.  
  12745.           XMSPUT
  12746.  
  12747.             PROTOTYPE
  12748.  
  12749.             extern int far xmsput (void far *sourcemem, int xmshandle,
  12750.             long offset, unsigned long count)
  12751.  
  12752.             INPUT
  12753.  
  12754.             sourcemem - source data in conventional memory
  12755.             xmshandle - handle of destination extended memory block
  12756.             offset - number of bytes from beginning of destination memory
  12757.             block
  12758.             count - number of bytes to copy from conventional memory to
  12759.             extended memory (must be even)
  12760.  
  12761.             OUTPUT
  12762.  
  12763.             XMSPUT returns 1 if the copy was successful, 0 otherwise.
  12764.  
  12765.             USAGE
  12766.  
  12767.             XMSPUT copies data from conventional memory to extended
  12768.             memory.  The number of bytes copied must be an even number and
  12769.             cannot be larger than 65536.  The destination may begin off
  12770.             the beginning of the extended memory block by specifying an
  12771.             non zero offset.  If the function was unsuccessful, check
  12772.             XMSERROR for error codes.
  12773.  
  12774.             SEE ALSO
  12775.  
  12776.             WHICHXMS, XMSALLOCATE, XMSCOPY, XMSERROR, XMSFREE, XMSGET
  12777.  
  12778.             EXAMPLE
  12779.  
  12780.             See XMSCOPY
  12781.  
  12782.  
  12783.  
  12784.  
  12785.  
  12786.  
  12787.  
  12788.  
  12789.  
  12790.  
  12791.  
  12792.  
  12793.  
  12794.  
  12795.  
  12796.  
  12797.  
  12798.  
  12799.  
  12800.  
  12801.                                                                         205
  12802.  
  12803.  
  12804.  
  12805.  
  12806.  
  12807.           XMSSCREENGET
  12808.  
  12809.             PROTOTYPE
  12810.  
  12811.             extern int far xmsscreenget ()
  12812.  
  12813.             INPUT
  12814.  
  12815.             no input parameters
  12816.  
  12817.             OUTPUT
  12818.  
  12819.             Used as a function, XMSSCREENGET returns the assigned XMS
  12820.             memory handle if successful, 0 otherwise.
  12821.  
  12822.             USAGE
  12823.  
  12824.             XMSSCREENGET stores the pixel data contained within the entire
  12825.             active screen.  The bitmap is stored such that the first
  12826.             integer in the allocated XMS block is the width and the second
  12827.             integer is the height.  These are followed by a long integer
  12828.             (4 bytes) specifying the total size of the allocated XMS
  12829.             block.  The remaining bytes are the bitmap raster data stored
  12830.             by rows starting at the top of the screen.  Note that this
  12831.             function is about twice as fast as using XMSBLKGET to save the
  12832.             entire screen.  If the function was unsuccessful, check
  12833.             XMSERROR for error codes.
  12834.  
  12835.             All allocated XMS blocks must be freed using XMSFREE before a
  12836.             program terminates or the memory is lost until the machine is
  12837.             rebooted.  Simply exiting a program will not free allocated
  12838.             extended memory blocks.
  12839.  
  12840.             SEE ALSO
  12841.  
  12842.             BLKGET, BLKPUT, XMSBLKGET, XMSBLKPUT, XMSERROR, XMSFREE,
  12843.             XMSSCREENPUT
  12844.  
  12845.             EXAMPLE
  12846.  
  12847.             /*
  12848.              * this will copy the whole sreen to xms and the redraw it
  12849.             from xms
  12850.              */
  12851.  
  12852.             #include <stdlib.h>
  12853.             #include <conio.h>
  12854.             #include "svgacc.h"
  12855.             #define randnum(size) (rand() % (int)(size))
  12856.  
  12857.             void main(void)
  12858.             {
  12859.                int i, handle, er, mem, handles,x1,y1,x2,y2,colr;
  12860.                char text[]="press a key...";
  12861.  
  12862.  
  12863.                                                                         206
  12864.  
  12865.  
  12866.  
  12867.  
  12868.  
  12869.  
  12870.                /* make sure xms is ready and available */
  12871.                if ( whichxms(&mem,&handles) ) {
  12872.                  if ((mem < 1) || (handles < 1)) {
  12873.                     printf("sorry...there is either no free xms or\n");
  12874.                     printf("no free handles\n");
  12875.                     exit(1);
  12876.                  }
  12877.                }
  12878.                else {
  12879.                  printf("sorry...no active xms memory manager
  12880.             found...\n");
  12881.                  printf("make sure you have an xms memory manager\n");
  12882.                  printf("(such as HIMEM.SYS) loaded\n");
  12883.                  exit(1);
  12884.                }
  12885.  
  12886.                if ( !whichvga() )
  12887.                  exit(1);
  12888.                if ( !res640() )
  12889.                  exit(1);
  12890.                fillscreen(10);
  12891.                for(i=0;i<=500;i++)
  12892.                {
  12893.                  x1 = randnum(maxx);
  12894.                  y1 = randnum(maxy);
  12895.                  x2 = randnum(maxx);
  12896.                  y2 = randnum(maxy);
  12897.                  colr = randnum(16);
  12898.                  drwline(1,colr,x1,y1,x2,y2);
  12899.                }
  12900.                drwbox(SET,15,0,0,maxx,maxy);
  12901.                handle = xmsscreenget();
  12902.                if ( !handle ) {
  12903.                  printf("opps there is some error...unable to allocate
  12904.             xms...\n");
  12905.                  printf("error # %d\n",xmserror());
  12906.                  er = xmsfree(handle);
  12907.                  exit(1);
  12908.                }
  12909.                drwstring(SET,10,0,text,0,0);
  12910.                getch();
  12911.                fillscreen(0);
  12912.                drwstring(SET,10,0,text,0,0);
  12913.                getch();
  12914.                er = xmsscreenput(handle);
  12915.                er = xmsfree(handle);
  12916.  
  12917.                getch();
  12918.                restext();
  12919.                exit(0);
  12920.             }
  12921.  
  12922.  
  12923.  
  12924.  
  12925.                                                                         207
  12926.  
  12927.  
  12928.  
  12929.  
  12930.  
  12931.           XMSSCREENPUT
  12932.  
  12933.             PROTOTYPE
  12934.  
  12935.             extern int far xmsblkput (int srcxmshandle)
  12936.  
  12937.             INPUT
  12938.  
  12939.             srcxmshandle - handle of source extended memory block
  12940.  
  12941.             OUTPUT
  12942.  
  12943.             Used as a function, XMSSCREENPUT returns a 1 if successful, 0
  12944.             otherwise.
  12945.  
  12946.             USAGE
  12947.  
  12948.             XMSSCREENPUT places the complete screen pixel data contained
  12949.             in xms memory referenced by srcxmshandle on the screen.  The
  12950.             current screen resolution must be the same as the saved screen
  12951.             resolution. this function is not bound by the current
  12952.             viewport.  If the function was unsuccessful, check XMSERROR
  12953.             for error codes.
  12954.  
  12955.             SEE ALSO
  12956.  
  12957.             BLKGET, BLKPUT, XMSBLKGET, XMSBLKPUT, XMSERROR, XMSFREE,
  12958.             XMSSCREENGET
  12959.  
  12960.             EXAMPLE
  12961.  
  12962.             See XMSSCREENGET
  12963.  
  12964.  
  12965.  
  12966.  
  12967.  
  12968.  
  12969.  
  12970.  
  12971.  
  12972.  
  12973.  
  12974.  
  12975.  
  12976.  
  12977.  
  12978.  
  12979.  
  12980.  
  12981.  
  12982.  
  12983.  
  12984.  
  12985.  
  12986.  
  12987.                                                                         208
  12988.  
  12989.  
  12990.  
  12991.  
  12992.  
  12993.           APPENDIX A.  SVGACC.H
  12994.  
  12995.           This is the header file containing function prototypes and
  12996.           structure definitions for SVGACC.LIB.  This file should be
  12997.           included in every program module that uses this library.  To
  12998.           properly include the header file, place the following line at the
  12999.           top of the every code module:
  13000.  
  13001.                                  #include "svgacc.h"
  13002.  
  13003.           Without these prototypes and definitions, the C/C++ compiler will
  13004.           be unable to compile any code module using the commands found in
  13005.           this library.
  13006.  
  13007.           /* SVGACC Include File for Microsoft compatible C/C++ compilers
  13008.            * Copyright 1993-1995 by Stephen L. Balkum and Daniel A. Sill
  13009.            * Zephyr Software P.O. Box 7704, Austin, Texas  78713-7704
  13010.            * Last Update 1/1/95
  13011.            */
  13012.  
  13013.           #ifndef SVGACC_H
  13014.           #define SVGACC_H
  13015.  
  13016.           typedef unsigned char byte;
  13017.  
  13018.           typedef struct {
  13019.             char r;
  13020.             char g;
  13021.             char b;
  13022.           } RGB;
  13023.  
  13024.           typedef RGB PaletteData[256];
  13025.  
  13026.           typedef struct {
  13027.             byte hotspotx;
  13028.             byte hotspoty;
  13029.             byte data[384];
  13030.           } MouseCursor;
  13031.  
  13032.           typedef struct {
  13033.             byte width;
  13034.             byte height;
  13035.             byte data[4096];
  13036.           } Font;
  13037.  
  13038.           typedef enum {
  13039.             NO_ACTION = 0,
  13040.             SET,
  13041.             XOR,
  13042.             OR,
  13043.             AND
  13044.           } PixelMode;
  13045.  
  13046.           typedef enum {
  13047.  
  13048.  
  13049.                                                                         209
  13050.  
  13051.  
  13052.  
  13053.  
  13054.  
  13055.             UNKNOWN = 0,
  13056.             ACUMOS,
  13057.             ATI,
  13058.             AHEADA,
  13059.             AHEADB,
  13060.             CHIPSTECH,
  13061.             CIRRUS,
  13062.             EVEREX,
  13063.             GENOA,
  13064.             NCR,
  13065.             OAKTECH,
  13066.             PARADISE,
  13067.             REALTEK,
  13068.             TRIDENT,
  13069.             TSENG3,
  13070.             TSENG4,
  13071.             VESA,
  13072.             VIDEO7,
  13073.             AVANCE,
  13074.             MXIC,
  13075.             PRIMUS
  13076.           } VGAChipset;
  13077.  
  13078.           typedef struct {
  13079.             unsigned int width;
  13080.             unsigned int height;
  13081.             byte data[1];
  13082.           } RasterBlock;
  13083.  
  13084.           typedef struct {
  13085.             int x;
  13086.             int y;
  13087.           } D2Point;
  13088.  
  13089.           typedef struct {
  13090.             int x;
  13091.             int y;
  13092.             int z;
  13093.           } D3Point;
  13094.  
  13095.           typedef struct {
  13096.             int eyex;
  13097.             int eyey;
  13098.             int eyez;
  13099.             int scrd;
  13100.             int theta;
  13101.             int phi;
  13102.           } ProjParameters;
  13103.  
  13104.           #ifdef __cplusplus
  13105.           extern "C" {
  13106.           #endif
  13107.  
  13108.           /* Global variables */
  13109.  
  13110.  
  13111.                                                                         210
  13112.  
  13113.  
  13114.  
  13115.  
  13116.  
  13117.           extern const int far maxx;
  13118.           extern const int far maxy;
  13119.           extern const int far viewx1;
  13120.           extern const int far viewy1;
  13121.           extern const int far viewx2;
  13122.           extern const int far viewy2;
  13123.  
  13124.           /* 'BLocK' methods to manipulate RasterBlocks on and off the
  13125.           screen */
  13126.  
  13127.           extern int  far blkget (int x1, int y1, int x2, int y2,
  13128.           RasterBlock far *gfxblk);
  13129.           extern void far blkput (PixelMode mode, int x, int y, RasterBlock
  13130.           far *gfxblk);
  13131.           extern void far blkresize (unsigned newxsize, unsigned newysize,
  13132.           RasterBlock far *sourcegfxblk, RasterBlock far *destgfxblk);
  13133.           extern int  far blkrotate (int ang, int backfill, RasterBlock far
  13134.           *sourcegfxblk, RasterBlock far *destgfxblk);
  13135.           extern int  far blkrotatesize (int ang, RasterBlock far
  13136.           *sourcegfxblk);
  13137.  
  13138.           /* 'BYTECOPY' method for fast memory copy */
  13139.  
  13140.           extern void far bytecopy (void far *src, void far *dst, unsigned
  13141.           long numbytes);
  13142.  
  13143.           /* '2D' methods to transform D2Points */
  13144.  
  13145.           extern void far d2rotate (int points, int xorigin, int yorigin,
  13146.           int ang, D2Point far *inary, D2Point far *outary);
  13147.           extern void far d2scale (int points, int xscale, int yscale,
  13148.           D2Point far *inary, D2Point far *outary);
  13149.           extern void far d2translate (int points, int xtrans, int ytrans,
  13150.           D2Point far *inary, D2Point far *outary);
  13151.  
  13152.           /* '3D' methods to transform D3Points */
  13153.  
  13154.           extern int  far d3project (int points, ProjParameters far
  13155.           *params, D3Point far *inary, D2Point far *outary);
  13156.           extern void far d3rotate (int points, int xorigin, int yorigin,
  13157.           int zorigin, int zrang, int yrang, int xrang, D3Point far *inary,
  13158.           D3Point far *outary);
  13159.           extern void far d3scale (int points, int xscale, int yscale, int
  13160.           zscale, D3Point far *inary, D3Point far *outary);
  13161.           extern void far d3translate (int points, int xtrans, int ytrans,
  13162.           int ztrans, D3Point far *inary, D3Point far *outary);
  13163.  
  13164.           /* 'DRaW' methods for placing text and graphics primitives on
  13165.           screen */
  13166.  
  13167.           extern void far drwaline (int colrbits, int colr, int x1, int y1,
  13168.           int x2, int y2);
  13169.           extern void far drwbox (PixelMode mode, int colr, int x1, int y1,
  13170.           int x2, int y2);
  13171.  
  13172.  
  13173.                                                                         211
  13174.  
  13175.  
  13176.  
  13177.  
  13178.  
  13179.           extern void far drwcirarc (PixelMode mode, int colr, int centerx,
  13180.           int centery, int radius, long startang, long endang);
  13181.           extern void far drwcircle (PixelMode mode, int colr, int centerx,
  13182.           int centery, int radius);
  13183.           extern void far drwcubicbezier (PixelMode mode, int colr, D2Point
  13184.           far *pon1, D2Point far *poff1, D2Point far *poff2, D2Point far
  13185.           *pon2);
  13186.           extern void far drwellarc (PixelMode mode, int colr, int centerx,
  13187.           int centery, int radiusx, int radiusy, long startang, long
  13188.           endang);
  13189.           extern void far drwellipse (PixelMode mode, int colr, int
  13190.           centerx, int centery, int radiusx, int radiusy);
  13191.           extern void far drwfillbox (PixelMode mode, int colr, int x1, int
  13192.           y1, int x2, int y2);
  13193.           extern void far drwfillcircle (PixelMode mode, int colr, int
  13194.           centerx, int centery, int radius);
  13195.           extern void far drwfillellipse (PixelMode mode, int colr, int
  13196.           centerx, int centery, int radiusx, int radiusy);
  13197.           extern void far drwline (PixelMode mode, int colr, int x1, int
  13198.           y1, int x2, int y2);
  13199.           extern void far drwpoint (PixelMode mode, int colr, int x, int
  13200.           y);
  13201.           extern void far drwstring (PixelMode mode, int fcolr, int bcolr,
  13202.           const char far *strng, int x, int y);
  13203.           extern void far drwstringdn (PixelMode mode, int fcolr, int
  13204.           bcolr, const char far *strng, int x, int y);
  13205.           extern void far drwstringlt (PixelMode mode, int fcolr, int
  13206.           bcolr, const char far *strng, int x, int y);
  13207.           extern void far drwstringrt (PixelMode mode, int fcolr, int
  13208.           bcolr, const char far *strng, int x, int y);
  13209.  
  13210.           /* 'FILL' methods for filling various regions on screen with a
  13211.           color */
  13212.  
  13213.           extern void far fillarea (int xseed, int yseed, int bordercolr,
  13214.           int fillcolr);
  13215.           extern void far fillconvexpoly (int colr, int points, D2Point far
  13216.           *inary);
  13217.           extern void far fillpoly (int colr, int points, D2Point far
  13218.           *inary);
  13219.           extern void far fillcolor (int xseed, int yseed, int oldcolr, int
  13220.           newcolr);
  13221.           extern void far fillpage (int colr);
  13222.           extern void far fillscreen (int colr);
  13223.           extern void far fillview (int colr);
  13224.  
  13225.           /* 'FONT' methods for setting the current font */
  13226.  
  13227.           extern void far fontgetinfo (int far *wdth, int far *hght);
  13228.           extern void far fontset (Font far *font);
  13229.           extern void far fontsystem (void);
  13230.  
  13231.           /* 'GET' methods to return information held by library */
  13232.  
  13233.  
  13234.  
  13235.                                                                         212
  13236.  
  13237.  
  13238.  
  13239.  
  13240.  
  13241.           extern void far getlaststring (RasterBlock far *strnggfxblk);
  13242.           extern long far getarccos (long cosvalue);
  13243.           extern long far getarcsin (long sinvalue);
  13244.           extern long far getarctan (long tanvalue);
  13245.           extern long far getcos (long angle);
  13246.           extern int  far getpoint (int x, int y);
  13247.           extern long far getsin (long angle);
  13248.           extern long far gettan (long angle);
  13249.  
  13250.           /* 'JOYSTICK' method to read joysticks' status */
  13251.  
  13252.           extern void far joystickinfo (int far *jax, int far *jay, int far
  13253.           *jabuts, int far *jbx, int far *jby, int far *jbbuts);
  13254.  
  13255.           /* 'MOUSE' methods to interact with mouse driver */
  13256.  
  13257.           extern void far mousebutpress (int reqbut, int far *xloc, int far
  13258.           *yloc, int far *num, int far *mbuts);
  13259.           extern void far mousebutrelease (int reqbut, int far *xloc, int
  13260.           far *yloc, int far *num, int far *mbuts);
  13261.           extern void far mousecursordefault (void);
  13262.           extern void far mousecursorset (MouseCursor far *mousecursor);
  13263.           extern void far mouseenter (void);
  13264.           extern void far mouseexit (void);
  13265.           extern void far mousehide (void);
  13266.           extern void far mouseinfo (int far *drvmajorver, int far
  13267.           *drvminorver, int far *mousetype, int far *irqnumber);
  13268.           extern void far mouselocset (int xloc, int yloc);
  13269.           extern void far mouserangeset (int x1, int y1, int x2, int y2);
  13270.           extern void far mouserestorestate (byte far *mousebuf);
  13271.           extern void far mousesavestate (byte far *mousebuf);
  13272.           extern void far mousesensset (int xsens, int ysens, int
  13273.           dblspdthresh);
  13274.           extern void far mouseshow (void);
  13275.           extern void far mousestatus (int far *x, int far *y, int far
  13276.           *mbuts);
  13277.           extern int  far mousestoragesize (void);
  13278.  
  13279.           extern void far overscanset (int colr);
  13280.  
  13281.           /* 'PAGE' methods to control paging abilities */
  13282.  
  13283.           extern int  far pageactive (int page);
  13284.           extern int  far pagedisplay (int x, int y, int page);
  13285.  
  13286.           /* 'PALette' methods to manipulate and activate palettes */
  13287.  
  13288.           extern void far palchgauto (RGB far *pal, RGB far *newpal, int
  13289.           firstcolr, int lastcolr, int speed);
  13290.           extern void far palchgstep (RGB far *pal, RGB far *newpal, int
  13291.           firstcolr, int lastcolr, int percent);
  13292.           extern void far palcopy (RGB far *srcpal, RGB far *destpal, int
  13293.           firstcolr, int lastcolr);
  13294.  
  13295.  
  13296.  
  13297.                                                                         213
  13298.  
  13299.  
  13300.  
  13301.  
  13302.  
  13303.           extern void far paldimstep (RGB far *pal, int firstcolr, int
  13304.           lastcolr, int percent);
  13305.           extern void far palget (RGB far *pal, int firstcolr, int
  13306.           lastcolr);
  13307.           extern void far palioauto (RGB far *pal, int firstcolr, int
  13308.           lastcolr, int speed);
  13309.           extern void far palrotate (RGB far *pal, int firstcolr, int
  13310.           lastcolr, int shift);
  13311.           extern void far palset (RGB far *pal, int firstcolr, int
  13312.           lastcolr);
  13313.  
  13314.           /* 'PCX' methods to read / write PCX files and place images on
  13315.           screen */
  13316.  
  13317.           extern int  far pcxgetinfo (const char far *name, int far
  13318.           *pcxxsize, int far *pcxysize, int far *numcolors, RGB far *pal);
  13319.           extern int  far pcxmake (int x1, int y1, int x2, int y2, const
  13320.           char far *name);
  13321.           extern int  far pcxput (PixelMode mode, int xloc, int yloc, const
  13322.           char far *name);
  13323.  
  13324.           /* 'RESolution' methods to set various video modes */
  13325.  
  13326.           extern int  far res320 (void);
  13327.           extern int  far res640 (void);
  13328.           extern int  far res640l (void);
  13329.           extern int  far res800 (void);
  13330.           extern int  far res1024 (void);
  13331.           extern int  far res1280 (void);
  13332.           extern int  far restext (void);
  13333.  
  13334.           /* 'SCROLL' methods for scrolling various sections of the screen
  13335.           */
  13336.  
  13337.           extern void far scrolldn (int x1, int y1, int x2, int y2, int
  13338.           num, int colr);
  13339.           extern void far scrolllt (int x1, int y1, int x2, int y2, int
  13340.           num, int colr);
  13341.           extern void far scrollrt (int x1, int y1, int x2, int y2, int
  13342.           num, int colr);
  13343.           extern void far scrollup (int x1, int y1, int x2, int y2, int
  13344.           num, int colr);
  13345.  
  13346.           /* 'Sync' DELAY method */
  13347.  
  13348.           extern void far sdelay (int count);
  13349.  
  13350.           /* 'SET' methods to adjust library internal variables */
  13351.  
  13352.           extern void far setcard (VGAChipset chip, int mem);
  13353.           extern void far setview (int x1, int y1, int x2, int y2);
  13354.  
  13355.           /* 'SPRITE' methods for manipulating sprites on and off screen */
  13356.  
  13357.  
  13358.  
  13359.                                                                         214
  13360.  
  13361.  
  13362.  
  13363.  
  13364.  
  13365.           extern int  far spritecolldetect (int transcolr, int x1, int y1,
  13366.           int x2, int y2, RasterBlock far *sprite1, RasterBlock far
  13367.           *sprite2);
  13368.           extern void far spritegap (int transcolr, int x, int y,
  13369.           RasterBlock far *sprite, RasterBlock far *spritebkgnd);
  13370.           extern void far spriteget (int transcolr, int x, int y,
  13371.           RasterBlock far *sprite, RasterBlock far *spritebkgnd);
  13372.           extern void far spriteput (PixelMode mode, int transcolr, int x,
  13373.           int y, RasterBlock far *sprite);
  13374.  
  13375.           /* 'VIDEO' methods to interact with video mode and display */
  13376.  
  13377.           extern int  far videomodeget (void);
  13378.           extern void far videomodeset (int videomode);
  13379.           extern void far videooff (void);
  13380.           extern void far videoon (void);
  13381.  
  13382.           /* 'Identification' methods to discover WHICH hardware is
  13383.           available */
  13384.  
  13385.           extern int  far whichcpu (void);
  13386.           extern int  far whichjoystick (void);
  13387.           extern int  far whichmem (void);
  13388.           extern int  far whichmouse (void);
  13389.           extern VGAChipset far whichvga (void);
  13390.           extern int  far whichxms (unsigned int far *xmskbytesavail,
  13391.           unsigned int far *xmshandlesavail);
  13392.  
  13393.           /* 'XMS' methods to store and retrieve extended memory */
  13394.  
  13395.           extern int  far xmsallocate (unsigned int reqkbytes);
  13396.           extern int  far xmsblkget (int x1, int y1, int x2, int y2);
  13397.           extern int  far xmsblkput (PixelMode mode, int x, int y, int
  13398.           xmshandle);
  13399.           extern int  far xmscopy (int xmssrchandle, long srcoffset, int
  13400.           xmsdesthandle, long destoffset, unsigned long count);
  13401.           extern int  far xmserror (void);
  13402.           extern int  far xmsfree (int xmshandle);
  13403.           extern int  far xmsget (int xmshandle, long offset, void far
  13404.           *destmem, unsigned long count);
  13405.           extern int  far xmsput (void far *sourcemem, int xmshandle, long
  13406.           offset, unsigned long count);
  13407.           extern int  far xmsscreenget (void);
  13408.           extern int  far xmsscreenput (int xmshandle);
  13409.  
  13410.           #ifdef __cplusplus
  13411.           }
  13412.           #endif
  13413.  
  13414.           #endif
  13415.           /* SVGACC_H */
  13416.  
  13417.  
  13418.  
  13419.  
  13420.  
  13421.                                                                         215
  13422.  
  13423.  
  13424.  
  13425.  
  13426.  
  13427.           APPENDIX B.  JOYSTICK PORTS AND Y-CABLES
  13428.  
  13429.           SCHEMATIC WIRING DIAGRAM FOR A STANDARD JOYSTICK PORT
  13430.  
  13431.                                     DB15 male
  13432.                                     connector
  13433.                    Joystick B            ___       Joystick A
  13434.                                       __/   |
  13435.                                      /    o | 1 -------------------+
  13436.              +------------------  9 | o     |     ___Button A      |
  13437.              |     Button A___      |     o | 2 --o o-+            |
  13438.              |           +-o o-- 10 | o     |         |    X Axis  |
  13439.              |  X Axis   |          |     o | 3 -------------+     |
  13440.              |     +------------ 11 | o     |         |      |     |
  13441.              |     |     |          |     o | 4 ------+      |     |
  13442.              +--/\/\/\   +------ 12 | o     |         |    /\/\/\--+
  13443.              |           |          |     o | 5       |            |
  13444.              |     +------------ 13 | o     |         |            |
  13445.              |     |     | ___      |     o | 6 -------------+     |
  13446.              |     |     +-o o-- 14 | o     |     ___ |      |     |
  13447.              |     |    Button B    |     o | 7 --o o-+      |     |
  13448.              |     |             15 | o     |   Button B   /\/\/\--+
  13449.              +--/\/\/\               \__  o | 8            Y Axis
  13450.                Y Axis                   \___|
  13451.  
  13452.           Notes:
  13453.  
  13454.           1)This diagram comes with NO warranties expressed or implied.
  13455.             It is provided for information only.  In no event shall
  13456.             Stephen L. Balkum, Daniel A. Sill or Zephyr Software be held
  13457.             liable for damages resulting from use, misuse, or inability to
  13458.             use this information.
  13459.  
  13460.           2)The x and y axis potentiometers have a typical range of 0 to
  13461.             100k ohms.  Buttons are normally open and close when pressed.
  13462.  
  13463.           3)This diagram is correct for joystick ports that conform to the
  13464.             standard set forth by IBM. Some specialty joystick cards
  13465.             provide separate A and B joystick connectors.  For these
  13466.             cards, both connectors are wired to pins 1 through 8 as shown
  13467.             in the diagram.
  13468.  
  13469.           4)Many 'Super I/O' boards (2H/2F/2S/1P/1G) equipped with a
  13470.             joystick port will support only one joystick.  On these cards,
  13471.             pins 9 through 15 are not used.
  13472.  
  13473.           5)Commercially available joysticks are wired to use pins 1
  13474.             through 8 and, therefore, will always be 'Joystick A' if
  13475.             plugged directly into a dual joystick port connector.
  13476.  
  13477.           6)Many sound cards provide joystick ports; however, their
  13478.             connector wiring does not always conform to the standard shown
  13479.             above.  Some of these connectors may be used for other
  13480.  
  13481.  
  13482.  
  13483.                                                                         216
  13484.  
  13485.  
  13486.  
  13487.  
  13488.  
  13489.             purposes such as a MIDI port.  See the documentation that
  13490.             comes with the sound card.
  13491.  
  13492.           7)If there is more than one joystick port on a computer
  13493.             configured to operate the same joystick, only ONE port should
  13494.             be enabled at any given time for proper operation.  Disable
  13495.             all but one joystick port.  For example, if the computer has
  13496.             both a Super I/O card and a sound card, the joystick port on
  13497.             the Super I/O card should be disabled since the sound card's
  13498.             port probably supports two joysticks and the I/O card supports
  13499.             only one.
  13500.  
  13501.  
  13502.  
  13503.  
  13504.  
  13505.  
  13506.  
  13507.  
  13508.  
  13509.  
  13510.  
  13511.  
  13512.  
  13513.  
  13514.  
  13515.  
  13516.  
  13517.  
  13518.  
  13519.  
  13520.  
  13521.  
  13522.  
  13523.  
  13524.  
  13525.  
  13526.  
  13527.  
  13528.  
  13529.  
  13530.  
  13531.  
  13532.  
  13533.  
  13534.  
  13535.  
  13536.  
  13537.  
  13538.  
  13539.  
  13540.  
  13541.  
  13542.  
  13543.  
  13544.  
  13545.                                                                         217
  13546.  
  13547.  
  13548.  
  13549.  
  13550.  
  13551.           SCHEMATIC WIRING DIAGRAM FOR A JOYSTICK Y-CABLE
  13552.  
  13553.                                              ___
  13554.                          DB15 male         __/   |
  13555.                        connector to       /    o | 1 --------+
  13556.                        Joystick Port   9 | o     |           |
  13557.                         on computer      |     o | 2 --------|-+
  13558.                             +-------- 10 | o     |           | |
  13559.                             |            |     o | 3 --------|-|-+
  13560.                             | +------ 11 | o     |           | | |
  13561.                             | |          |     o | 4 --------|-|-|-+
  13562.                             | |       12 | o     |           | | | |
  13563.                             | |          |     o | 5         | | | |
  13564.                             | | +---- 13 | o     |           | | | |
  13565.                             | | |        |     o | 6 --------|-|-|-|-+
  13566.                             | | | +-- 14 | o     |           | | | | |
  13567.                             | | | |      |     o | 7 --------|-|-|-|-|-+
  13568.                             | | | |   15 | o     |           | | | | | |
  13569.                             | | | |       \__  o | 8         | | | | | |
  13570.                             | | | |          \___|           | | | | | |
  13571.                             | | | |                          | | | | | |
  13572.                             | | | |                          | | | | | |
  13573.                             | | | |  +-----------------------+ | | | | |
  13574.                             | | | |  |                       | | | | | |
  13575.                             | | | |  | +---------------------|-|-|-+ | |
  13576.                             | | | |  | |                     | | | | | |
  13577.                             | | | |  | |                     | | | | | |
  13578.            DB15 female      | | | |  | |     DB15 female     | | | | | |
  13579.            connector to     | | | |  | |     connector to    | | | | | |
  13580.             Joystick B      | | | |  | |      Joystick A     | | | | | |
  13581.                   ___       | | | |  | |            ___      | | | | | |
  13582.                __/   |      | | | |  | |         __/   |     | | | | | |
  13583.               /    o | 1 ---|-|-|-|--+ |        /    o | 1 --+ | | | | |
  13584.            9 | o     |      | | | |    |     9 | o     |       | | | | |
  13585.              |     o | 2 ---+ | | |    |       |     o | 2 ----+ | | | |
  13586.           10 | o     |        | | |    |    10 | o     |         | | | |
  13587.              |     o | 3 -----+ | |    |       |     o | 3 ------+ | | |
  13588.           11 | o     |          | |    |    11 | o     |           | | |
  13589.              |     o | 4 -------|-|----+       |     o | 4 --------+ | |
  13590.           12 | o     |          | |         12 | o     |             | |
  13591.              |     o | 5        | |            |     o | 5           | |
  13592.           13 | o     |          | |         13 | o     |             | |
  13593.              |     o | 6 -------+ |            |     o | 6 ----------+ |
  13594.           14 | o     |            |         14 | o     |               |
  13595.              |     o | 7 ---------+            |     o | 7 ------------+
  13596.           15 | o     |                      15 | o     |
  13597.               \__  o | 8                        \__  o | 8
  13598.                  \___|                             \___|
  13599.  
  13600.           Notes:
  13601.  
  13602.           1)This diagram comes with NO warranties expressed or implied.
  13603.             It is provided for information only.  In no event shall
  13604.             Stephen L. Balkum, Daniel A. Sill or Zephyr Software be held
  13605.  
  13606.  
  13607.                                                                         218
  13608.  
  13609.  
  13610.  
  13611.  
  13612.  
  13613.             liable for damages resulting from use, misuse, or inability to
  13614.             use this information.
  13615.  
  13616.           2)This cable has worked with a standard joystick port connector,
  13617.             a Sound Blaster port connector, and a Sound Blaster Pro
  13618.             joystick port connector.
  13619.  
  13620.  
  13621.  
  13622.  
  13623.  
  13624.  
  13625.  
  13626.  
  13627.  
  13628.  
  13629.  
  13630.  
  13631.  
  13632.  
  13633.  
  13634.  
  13635.  
  13636.  
  13637.  
  13638.  
  13639.  
  13640.  
  13641.  
  13642.  
  13643.  
  13644.  
  13645.  
  13646.  
  13647.  
  13648.  
  13649.  
  13650.  
  13651.  
  13652.  
  13653.  
  13654.  
  13655.  
  13656.  
  13657.  
  13658.  
  13659.  
  13660.  
  13661.  
  13662.  
  13663.  
  13664.  
  13665.  
  13666.  
  13667.  
  13668.  
  13669.                                                                         219